Mastering Oracle ADF Bindings: Advanced Techniques Oracle OpenWorld 2014 About Me Mastering Oracle ADF Bindings: Advanced Techniques Sten Vesterli [email protected] Oracle OpenWorld Sep 2014 • • • • • • • Sten Vesterli! Developer, consultant, trainer! 20 years of Oracle experience! Partner in Scott/Tiger! Oracle ACE Director! ADF Certified! Author of “Oracle ADF Enterprise Application Development – Made Simple” (2011, 2014)! Who is Scott/Tiger? Scott/Tiger customers Tiger Scott Bruce Scott (Oracle employee no. 4) Bruce’s daughter’s cat Also an Oracle-focused consultancy based in Denmark… ADF Bindings Skill Levels • • • • • [email protected] © Sten Vesterli 2014 Novice! Apprentice! Journeyman! Master! Artisan! 1 Mastering Oracle ADF Bindings: Advanced Techniques Oracle OpenWorld 2014 Skill Levels • Novice! Skill Levels • Master! – Doesn’t know what bindings are! • Apprentice! – Can read the bindings tab! – Can get binding from component! – Can use dynamic bindings! • Artisan! – Can create bindings programmatically! • Journeyman! – Can create static bindings! – Can use bindings programmatically! Quote of the Day Automagic binding • Databindings.cpx! • xxPagedef.xml! • web.xml change! Binding screen Bindings • Value! – Attribute Value! – List! – Tree! – Button (boolean)! – Graph! • Action! – Action (built-in)! – Method action! [email protected] © Sten Vesterli 2014 2 Mastering Oracle ADF Bindings: Advanced Techniques Oracle OpenWorld 2014 Executables • • • • • • • Iterator! Method Iterator (custom methods)! Variable! Page (to template)! Search Region! Task Flow! Multi Task Flow ! (unknown no. of regions)! Log Target URL -- http://127.0.0.1:7101/EmpDeptAppEmpDeptView-context-root/faces/untitled1.jsf <oracle.adf.model> <BindingContext> <put> <[316] Replacing: null with: com_vesterli_demo_view_untitled1PageDef> <oracle.adf.model> <DCExecutableBinding> <refreshIfNeeded> <[317] Invoke refresh for :DeptView1Iterator> <oracle.adf.model> <DCIteratorBinding> <refresh> <[318] Executing and syncing on IteratorBinding.refresh from :DeptView1Iterator> <oracle.adf.model> <BindingContext> <put> <[319] BindingContext.put non -dc / bc entry( _app_def_name_key_EmpDeptServiceDataControl_, com.vesterli.demo.view.DataBindings.cpx )> ADF Lifecycle Bindings at Runtime • Databindings.cpx! – BindingContext! • xxPagedef.xml! – BindingContainer! • Iterator! – DCIteratorBinding! Log <oracle.adf.model> <ViewObjectImpl> <buildQuery> <[375] SELECT Dept.DEPTNO, Dept.DNAME, Dept.LOC FROM DEPT Dept> <oracle.adf.model> <ViewObjectImpl> <getPreparedStatement> <[376] ViewObject: [com.vesterli.demo.model.view.DeptView]EmpDeptService.Dept View1 Created new QUERY statement> <oracle.adf.model> <ViewObjectImpl> <bindParametersForCollection> <[377] Bind params for ViewObject: [com.vesterli.demo.model.view.DeptView]EmpDeptService.Dept View1> … <oracle.adf.model> <DCIteratorBinding> <releaseDataInternal> <[381] Releasing iterator binding:DeptView1Iterator> Using Bindings BindingContext bctx = BindingContext.getCurrent(); BindingContainer bc = bctx.getCurrentBindingsEntry(); [email protected] © Sten Vesterli 2014 3 Mastering Oracle ADF Bindings: Advanced Techniques Oracle OpenWorld 2014 Attribute binding AttributeBinding ab = (AttributeBinding)bc. getControlBinding("Dname"); • Get with ab.getInputValue() • Set with ab.setInputValue() Operations Binding OperationBinding ob = bc.getOperationBinding("OprName"); ob.execute(); • To set parameters, first get parameter map! – getParamsMap() • Check for errors ! – getErrors() Component à Binding Iterator Binding DCBindingContainer dcb = (DCBindingContainer)bc; DCIteratorBinding iter = (DCIteratorBinding)dcb. findIteratorBinding("IterName"); • To get one row! – getCurrentRow() • To get rowset! – getAllRowsInRange()! • I have a component where something happened (e.g. a table)! • I want to work with the data on that component! • So I need to get from the component back to the binding! Component à Binding Dynamic Binding • Need handle to component (Binding property)! RichTable table1 = this.getTable1(); CollectionModel tableModel = (CollectionModel)table1.getValue(); JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)tableModel. getWrappedData(); DCIteratorBinding iter = treeBinding.getDCIteratorBinding(); [email protected] © Sten Vesterli 2014 I wonder what this one does? 4 Mastering Oracle ADF Bindings: Advanced Techniques Dynamic Page <af:iterator id="i1" value="#{bindings. EmpView1.attributesModel.attributes}” var="column" rows="0"> <af:column headerText="#{column.label}” id="c1”> <af:dynamicComponent id="d2" attributeModel="#{column}” value="#{row.bindings[column.name]. inputValue}"/> </af:column> </af:iterator> But now we’re free… • Since table will just loop over attributes, we can make the <iterator> dynamic! <iterator … DataControl= "EmpDeptServiceDataControl" id="${pageFlowScope.myBean.myIter}” /> • $ instead of # to achieve eager (early) evaluation! • Could also use dynamic Data Control! Oracle OpenWorld 2014 Dynamic Binding • <AttrNames> is empty! • Otherwise normal binding! Do you need this? • Dynamic bindings are rare! • They will be hard to maintain! • Question the use case! – Typically not necessary! – Users want “one system to end them all” with enough flexibility that they never have to speak to a programmer again! – Flexibility rarely used! ! Creating a binding • • • • • JUCtrlActionBinding! JUCtrlAttrsBinding! JUCtrlHierBinding! JUCtrlListBinding! … and many others! Creating a List Binding • Start with JUMetaObjectManager! – getJUMom()! – getControlDefFactory! • From here, get a JUCtrlValueDef! • Set parameters in hashmap and init()! • Create JUCtrlListBinding from the def! – createControlBinding();! • Add to binding context! – addControlBinding();! [email protected] © Sten Vesterli 2014 5 Mastering Oracle ADF Bindings: Advanced Techniques Oracle OpenWorld 2014 Artisan Level! • Worked example by Eugene Fedorenko! – adfpractice-fedor.blogspot.com/2014/02/ dynamic-lov-binding.html! You don’t need this • Or do you? ! – Let’s discuss use cases! More ADF • • • • ADF EMG! ODTUG! ADF Mastery newsletter! Win a free book! – Sign up at www.adfmastery.com! Q& A Twitter: @stenvesterli Blog: www.vesterli.com Web: www.adfmastery.com Email: [email protected] [email protected] © Sten Vesterli 2014 6
© Copyright 2024 ExpyDoc