The Tie That Binds: An Introduction to ADF Bindings

Similar documents
If you wish to make an improved product, you must already be engaged in making an inferior one.

ADF On-Ramp: What You Need to Know to Use the ADF Fusion Technology Stack. What is ADF and Fusion? ADF core technologies. Required languages.

ADF Code Corner. 016-How-to customize the ADF Faces Table Filter. Abstract: twitter.com/adfcodecorner

Introduction to ADF Core Technologies

Oracle ADF On-Ramp: Developing Applications With the Core ADF Stack

Oracle ADF On Ramp: What You Need to Know to Use ADF

ADF On-Ramp: What You Need to Know to Use ADF. What is ADF and Fusion? ADF core technologies. Required languages. Survey. Agenda. On the Positive Side

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

Achieving the Perfect Layout with ADF Faces RC

Hello Worldwide Web: Your First JSF in JDeveloper

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

ADF Mobile Code Corner

Don t get it right, just get it written.

The Arrangement of the Screens: Introduction to Layout in ADF Faces

ADF Code Corner. 70. How-to build dependent list boxes with Web Services Business Services. Abstract: twitter.com/adfcodecorner

The End of the Beginning: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

Agenda Birds Do It: Migrating Forms to Java EE Web A Case Study

ADF Code Corner How-to restrict the list of values retrieved by a model driven LOV. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to use the af:autosuggestbehavior component tag with ADF bound data sources. Abstract: twitter.

ADF Hands-On. Understanding Task Flow Activities / 2011 ADF Internal Enterprise 2.0 Training. Abstract:

We didn t need dialogue. We had faces.

Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part III:

ADF ON RAMP: WHAT YOU NEED TO KNOW TO USE ADF

Unraveling the Mysteries of J2EE Web Application Communications

ADF Code Corner. 64. How-to implement a Select Many Shuttle with pre- selected values. Abstract: twitter.com/adfcodecorner

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. Abstract: twitter.com/adfcodecorner

Survey. ADF On-Ramp: What You Need to Know to Use the ADF Fusion Technology Stack. Agenda. Raffle at the End

ADF Code Corner. 90. Filtering ADF bound lists. Abstract: twitter.com/adfcodecorner

Oracle Developer Day

Oracle Fusion Developer Guide (ISBN: ) Preview Chapter 1. The Quick Lerner s Guide to Oracle Fusion Web Application Development PREVIEW

Oracle Retail Accelerators for WebLogic Server 11g

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

<Insert Picture Here> Advanced ADF Faces. Frank Nimphius Principal Product Manager

Oracle Fusion Middleware 11g: Build Applications with ADF I

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

FILE XML DATABASE DEVELOPERS ORACLE 11G MANUAL EBOOK

Oracle Fusion Middleware 11g: Build Applications with ADF I

You CAN Judge a Book by Its Cover: Modern User Interface Design Principles

Oracle Developer Day

Design Modernization Case Study: Applying Mobile App Design Principles to the UTOUG Website

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

Oracle SQL Developer Workshop

Mastering Oracle ADF Task Flows. Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF

... AND UIX BEGAT ADF FACES: HOW RICH IS ADF FACES RICH CLIENT? Peter Koletzke, Quovera

Oracle ADF: The technology behind project fusion. Lynn Munsinger Principal Product Manager Application Development Tools Oracle Corporation

Oracle Fusion Middleware

Made from the Same Mold: Templating Approaches for ADF Faces Applications

J2EE for Oracle Technologists

ADF Code Corner. The Oracle JDeveloper Forum Harvest 10 / Abstract: twitter.com/adfcodecorner

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

ADF Mobile Code Corner

ADF Code Corner How-to launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part I:

Oracle Application Development Framework Overview

1z0-554qa88. Number: Passing Score: 800 Time Limit: 120 min File Version: 1.0. Oracle 1z0-554

MVC. Peter Koletzke, Quovera. Figure 1. MVC layers

Oracle Fusion Middleware

CHAPTER. Introduction to the Oracle Application Development Framework

<Insert Picture Here> Oracle JHeadstart Forms2ADF - Overview

<Insert Picture Here> Accelerated Java EE Development: The Oracle Way

Just Get It Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console Hands on Practice

Quick Web Development using JDeveloper 10g

Contents I Introduction 1 Introduction to PL/SQL iii

ADF Code Corner. Oracle JDeveloper OTN Harvest 10 / Abstract: twitter.com/adfcodecorner

ADF Code Corner. Oracle JDeveloper OTN Harvest 12 / 2011 & 01 / Abstract: twitter.com/adfcodecorner

Oracle Developer Day

Using SQL Developer. Oracle University and Egabi Solutions use only

ADF Mobile Code Corner

ADF Code Corner. Oracle JDeveloper OTN Harvest 02 / Abstract: twitter.com/adfcodecorner

Oracle Fusion Middleware

DEPLOYING APPLICATIONS TO WEBLOGIC SERVER USING JDEVELOPER AND WLS CONSOLE: JUST GET IT WRITTEN Peter Koletzke, Quovera and Duncan Mills, Oracle

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Oracle Exam 1z0-419 Oracle Application Development Framework 12c Essentials Version: 7.0 [ Total Questions: 87 ]

The JSF Tools Project

PassGuide..1z0-554_81,Q&A

1z0-419.exam.53q.

Managing Your Database Using Oracle SQL Developer

Oracle Developer Day

Manipulating Data. Copyright 2004, Oracle. All rights reserved.

Rich Web UI made simple Building Data Dashboards without Code

Chapter. An Introduction to Oracle JDeveloper and Oracle ADF

Oracle WebLogic Server Application Security

<Insert Picture Here> The Latest E-Business Suite R12.x OA Framework Rich User Interface Enhancements

An Oracle White Paper June Guidelines for Creating Task Flows to Be Used in Oracle Composer-Enabled Pages

Oracle Education Partner, Oracle Testing Center Oracle Consultants

Real Life ADF Mobile. 10 things that you don't get from the developer guide

Case Study: Redeveloping an Oracle Forms application using Oracle JDeveloper and Oracle ADF

In this Tutorial we present tips and trick for the development enviroment eclipse and the extension MyEclipse.

Oracle Internal & Oracle Academy

Oracle Reports Developer 10g: Build Reports

Chapter 2 FEATURES AND FACILITIES. SYS-ED/ Computer Education Techniques, Inc.

6/13/2012. Sneak Preview: Oracle JDeveloper 12c New Features. Frank Nimphius Senior Principal Product Manager Oracle Development Tools

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Course Overview. Copyright 2010, Oracle and/or its affiliates. All rights reserved.

ADF Code Corner. Oracle JDeveloper OTN Harvest 01 / Abstract: twitter.com/adfcodecorner

Building Rich Enterprise JSF Applications with Oracle JHeadstart for ADF (11.1.1)

ADF Code Corner How-to build a reusable toolbar with Oracle ADF Declarative Components. Abstract: twitter.com/adfcodecorner

Database Programming with PL/SQL

Using DbVisualizer Variables

Transcription:

The Tie That Binds: An Introduction to ADF Bindings Bindings Are Like This Peter Koletzke Technical Director & Principal Instructor 2 Survey Traditional Oracle development (Forms, Reports, Designer, PL/SQL) 1-2 years? More than 2 years? Java development 1-3 years? 4-17 years? 17+ years? JDeveloper 1-2 years? 2+ years? Overview Agenda Working with Bindings Binding Examples Slides will be available on the Quovera and UTOUG websites. Additional information in the appendixes. 3 4

Review: ADF Model (ADFm) A layer of ADF ADF Bindings Bindings provide objects to link to components ADF Data Controls Automatically bound sets of components Communication from Business Services to View and Controller layers One common layer for all types of business services E.g., EJB, ADF BC, web services Code to access any business service works the same way Application Client View Struts Model ADF Bindings Controller ADF Data Controls Web Client Business Services JSF ADF Bindings Association of a business service data element or action with a UI control Not automatic in native Java EE Relatively automatic in Oracle Forms Binding normally takes a lot of coding One-off solution is not the answer Need a framework to assist User Interface Data Bindings ADF Business Components Employees ID FirstName LastName Database EMPLOYEES Susan 5 6 View Layer ADF Model Components Each control on the page can use bindings Bindings expose actions to buttons and links Commit, Rollback, First, Last Bindings expose data to input items FirstName, LastName, Email, HireDate Page Control Control Page Control Control Control Binding Context Binding Container Binding Binding Binding Container Binding Binding Binding Data Control Data Control Business Components Layer Agenda Overview Working with Bindings Binding Examples Creating/Accessing PageDef file DataBindings.cpx 7 8

Creating Bindings Automatically Drag and drop control from the Data Control panel Automatically appears when editing a JSF JSP OR Ctrl-Shift-D This creates and binds UI items Nodes for Data control Data collection Attribute Nested data collection Operation Method Accessing Bindings Manually Progammatically, you use java.util.map An interface for organizing data Stores elements data of any Object type The bindings map contains all the bindings in the current page s binding container You can access these bindings using Expression Language #{bindings.salary} Salary mainmap bindings Next 9 10 Expression Language A.k.a.: JSP Expression Language EL Part of JavaServer Pages Standard Tag Language (JSTL) Procedural language within tags foreach; if; choose; set; when Many other technologies can use it JSF, UIX, Struts, Swing Can be used to refer to elements stored in maps Collections of objects EL Syntax All EL expressions have the form ${ } or #{ } JSF uses the # variation for component properties Refer to map elements by specifying the path to the element within the map, separated by. The main map is determined by context #{submap.subsubmap1.object3} ${object1} #{object2} object1 object2 mainmap submap subsubmap1 subsubmap2 object3 #{submap.subsubmap2.object4} object4 11 12

EL for ADF ADF s submap is bindings You can use EL expressions that refer to this map in attribute values, e.g. <af:inputtext value="#{bindings.employeeid.inputvalue}" label="#{bindings.employeeid.label}"/> The af:inputtext label and value are derived from the bindings context EmployeeId a submap referring to the ADF BC view object instance In Forms, those EL expressions are like this: Creating the Expression JSF expressions use the # prefix Distinguishes them from JSTL expressions Use the Expression Builder GET_ITEM_PROPERTY('EMP.EMPLOYEE_ID',DATABASE_VALUE); GET_ITEM_PROPERTY('EMP.EMPLOYEE_ID',PROMPT_TEXT); 13 14 Programmatic Access to Bindings Double click a bound button to generate the backing bean binding code, like this: public String saveaction() { BindingContainer bindings = getbindings(); OperationBinding operationbinding = bindings.getoperationbinding("commit"); Object result = operationbinding.execute(); if (!operationbinding.geterrors().isempty()) { return null; } return null; } Agenda Overview Working with Bindings Binding Examples Creating/Accessing PageDef file DataBindings.cpx 15 16

The Bindings File The page definition (or PageDef) XML file stores binding definitions for the page One PageDef file for each JSP Called filenamepagedef For example; editemployeepagedef.xml Created when you drag a data control to the page the first time You can create the file manually Maintained as you drag or delete components You can edit manually Viewing/Editing the PageDef Navigator OR Bindings tab on the JSF page Click here to open PageDef file 17 18 Contents of the PageDef File Executables Definitions of actions that will be run when the PageDef file is loaded Like trigger code in Forms Bindings Values and operations required on the page 19 PageDef Snippet: Bindings <pagedefinition xmlns=http://xmlns.oracle.com/adfm/uimodel... <bindings> <attributevalues id="employeeid" IterBinding="AllEmployeesIterator"> <AttrNames> <Item Value="EmployeeId"/> </AttrNames> </attributevalues> <action id="commit" InstanceName="TuhraServiceDataControl" DataControl="TuhraServiceDataControl" RequiresUpdateModel="true" Action="100"/> <list id="allemployeesjobid" IterBinding="AllEmployeesIterator" StaticList="false" ListOperMode="0" ListIter="AllJobsIterator" NullValueFlag="1" NullValueId="AllEmployeesJobId_null"> <AttrNames> <Item Value="JobId"/> </AttrNames> <ListAttrNames> <Item Value="JobId"/> </ListAttrNames> <ListDisplayAttrNames> <Item Value="JobTitle"/> </ListDisplayAttrNames> </list> </bindings>

Creating Bindings Alternative 1 Use the Structure window for the PageDef file Right-click menu on the bindings node Creating Bindings Alternative 2 Bindings tab on the JSPX page Or Overview tab in the PageDef file 21 22 Editing Bindings the Alternatives PageDef (Overview tab) or page (Bindings tab) Code Editor for the PageDef file Or select Go to Binding from a UI component Or select Go to Properties from the right-click menu on a binding in the Structure window Or select the binding in the Structure window and use the Property Inspector Agenda Overview Working with Bindings Binding Examples Creating/Accessing PageDef file DataBindings.cpx 23 24

DataBindings.cpx DataBindings.cpx DC Usages <datacontrolusages> <BC4JDataControl id="hrservicedatacontrol" Package="hr.model" FactoryClass="oracle.adf.model.bc4j.DataControlFactoryImpl" SupportsTransactions="true" SupportsFindMode="true" SupportsRangesize="true" SupportsResetState="true" SupportsSortCollection="true" Configuration="HRServiceLocal" syncmode="immediate xmlns="http://xmlns.oracle.com/adfm/datacontrol"/> </datacontrolusages> PageDef file mappings PageDef locations Data Control usages Last section in overview editor ADF BC data control (BC4J) ID for data control used 25 26 View editemployees.jspx First Name #{bindings.firstname.inputvalue} Business Services HRService.xml (application module) Inside the Walls Model editemployeespagedef.xml <executables> <iterator Binds="AllEmployees DataControl="HRServiceDataControl id="employeesbydeptiterator"> <bindings> <attributevalues IterBinding= "EmployeesByDeptIterator id="firstname"> Agenda Overview Working with Bindings Binding Examples Employees AllEmployees FirstName JDBC DataBindings.cpx <BC4JDataControl id="hrservicedatacontrol Configuration="HRServiceLocal" 27 28

Common Binding Types Attribute For single attribute in a collection List For data-bound list elements List of Values For view object lists of values Tree hierarchical controls (master detail) and tables Table (or range) For table components bound to collections (not used much now) Boolean For checkboxes Action For standard operations like Commit Method For custom methods Attribute Bindings A single view attribute value on the iterator binding s current view row Example: DepartmentId #{bindings.departmentid.inputvalue} (returns 2500 ) mainmap bindings DepartmentId label #{bindings.departmentid.label} (returns Department ID ) 29 30 Attribute Bindings and JSF You can access attribute bindings from any component attribute <af:outputtext value="#{bindings.departmentid.inputvalue}" /> Other component attributes access properties on the Model level object Control hints or attribute properties (for example, label and width): <af:inputtext value="#{bindings.phonenumber.inputvalue}" label="#{bindings.phonenumber.label}" columns="#{bindings.phonenumber.displaywidth}"/> JSF Code Snippets <af:inputtext value="#{bindings.departmentid.inputvalue}" label="#{bindings.departmentid.hints.label}" required="#{bindings.departmentid.hints.mandatory}" columns="#{bindings.departmentid.hints.displaywidth}" maximumlength="#{bindings.departmentid.hints.precision}" shortdesc="#{bindings.departmentid.hints.tooltip}" id="it1"> </af:inputtext> PageDef <bindings> <attributevalues IterBinding="DepartmentsView1Iterator" id="departmentid"> <AttrNames> <Item Value="DepartmentId"/> </AttrNames> </attributevalues> 31 32

Tree Bindings Used for tables, tree-tables and trees Expose data from all rows in the iterator binding s current range Can also be used for master-detail Expose some or all columns Iterator s collectionmodel property is used as the table s value A variable is assigned to the table binding s data Usually row Tree Binding Map Example: AllDepartments Contains rangeset and labels mainmap bindings AllDepartments rangeset labels DepartmentId DepartmentName ManagerId 33 34 PageDef Snippets JSF Snippet: af:table <bindings> <table id="allemployees" IterBinding= "EmpResultsIterator"> <AttrNames> <Item Value="EmployeeId"/> <Item Value="FirstName"/> <Item Value="LastName"/> <Item Value="Email"/> <Item Value="PhoneNumber"/> <Item Value="HireDate"/> <Item Value="JobId"/> <Item Value="Salary"/> <Item Value="ManagerId"/> </AttrNames> </table> Table Binding <executables> <iterator id="empresultsiterator" RangeSize="10" Binds="AllEmployees DataControl= "TuhraServiceDataControl"/> <iterator id="alljobsiterator" RangeSize="-1" Binds="AllJobs DataControl= "TuhraServiceDataControl"/> </executables> Iterator <af:table value="#{bindings.allemployees.collectionmodel}" var="row" rows="#{bindings.allemployees.rangesize}" first="#{bindings.allemployees.rangestart}" selectionstate= "#{bindings.allemployees.collectionmodel.selectedrow}" selectionlistener= "#{bindings.allemployees.collectionmodel.makecurrent}" width="100%"> <af:column headertext="#{bindings.allemployees.labels.employeeid}" sortproperty="employeeid" sortable="true"> <af:outputtext value="#{row.employeeid}"/> </af:column> <af:column headertext="#{bindings.allemployees.labels.firstname}" sortproperty="firstname" sortable="true"> <af:outputtext value="#{row.firstname}"/> </af:column> 35 Appendix A: more binding examples 36

Action Bindings Added when buttons or links are dropped into the UI Run operations Collection operations Create, Delete, Find, First, Last, etc. Data control operations Commit, Rollback JSF <af:commandbutton text="save" actionlistener="#{bindings.commit.execute}" disabled="#{!bindings.commit.enabled}"/> PageDef <action id="commit" RequiresUpdateModel="true" Action="commitTransaction" DataControl="HRServiceDataControl"/> What is an Iterator? A pointer to a row in a collection Allows manipulation of attribute values in a row Used to navigate a set of rows Much like a cursor navigating a query in PL/SQL You implicitly refer to these in binding expressions: #{bindings.employeeid.inputvalue} The employee ID of whatever row is currently pointed to by the iterator Can define more than one iterator per collection To have different pointers to the same collection E.g., if the same collection were used for two purposes like a search form and a read-only results table 37 38 Iterator An Executable These keep track of the current view row in a view object instance s query result Keeps track of a range of data around the view row View Object Instance Current row Current range I d Hammer in the Morning All parts should go together without forcing... By all means, do not use a hammer. 1925 IBM Maintenance Manual Raffle Appendix B: more about executables 39 40

Summary ADF Model layer connects the ADF Controller or View and Business Services layers ADF Data Bindings provide association of UI components and business services Simple coding in EL (and XML) tap into the ADF Model framework code XML code in the PageDef file defines the bindings EL in the UI properties access the binding by name Different types of bindings accomplish different tasks Designer Handbook ORACLE9i JDeveloper Handbook Developer Advanced Forms & Reports ORACLE JDeveloper 10g Handbook JDeveloper 3 Handbook Ch. 14-15 Books co-authored with Dr. Paul Dorsey, Avrom Roy-Faderman, & Duncan Mills www.quovera.com Founded in 1995 as Millennia Vision Corp. Profitable without outside funding Consultants each have 10+ years industry experience Strong High-Tech industry background 200+ clients/300+ projects JDeveloper Partner More technical white papers and presentations on the web site 41 42 Appendixes A: More Binding Examples B: More About Iterators and Executables Table Bindings A.k.a., range bindings Expose data from all rows in the iterator binding s current range Expose some or all columns Iterator s collectionmodel property is used as the table s value A variable in the table UI component is assigned to the table binding s data Usually row 43 44

List Bindings Populate a single attribute in the current row, or navigate between rows Dynamic or static Generally used as the value attribute for a pulldown list or similar element <af:selectonechoice value="#{bindings.allemployeesjobid.inputvalue}" /> List Bindings and Maps Example: a list for DepartmentId mainmap bindings DepartmentId displaydata label 45 46 List Binding Modes For populating an attribute, a list binding can be in static or dynamic list Static allows you to hard code the list Dynamic lets you specify a collection as the source For navigating, a list binding uses Navigation mode The iterator binding will jump to the row selected in the list Navigation List Bindings Changes the current row in the iterator Selecting a value from a navigation list sets that row as current This List Binding Editor appears when you drop a collection as a navigation list 47 48

List of Values Bindings Used for ADF LOV input list or ADF LOV choice list Popup LOV dialog List elements are displayed from the view object Any number of columns Provides search capabilities More functionality than a standard list binding Can also display a quick selection list Values displayed in a pulldown not popup Method Bindings Used for custom code Otherwise, identical in results to action bindings Drop the method from the Data Controls panel as a parameter form or button or link Creates a methodaction binding type Can also create the binding manually 49 50 Appendixes A: More Binding Examples B: More About Iterators and Executables Iterators Are Necessary Almost all other kinds of bindings must be associated with an iterator Exceptions: are bindings to actions E.g., Commit and Rollback, Do not apply to a particular query result 51 52

Iterator Details Consider this binding: #{bindings.employeeid.inputvalue} The employee ID of whatever record is currently pointed to by the iterator Iterators are defined in the PageDef file executables section The query associated with the iterator s view object is run when the page loads If more than one iterator per collection, the query executes once Important property: rangesize Number of rows fetched (-1 is all) InvokeAction - Another Executable Calls an existing action or method binding defined in action bindings Example: Create binding will add a row to the collection invokeaction on the binding will execute this operation Important property: Refresh Specifies when this invokeaction occurs ifneeded framework decides always every time the page is invoked 53 54 Action and ActionListener Properties Used on action components af:commandbutton, af:commandlink An actionlistener executes before the main action of the component, e.g., <af:commandbutton actionlistener="#{bindings.rollback.execute}" text="cancel" action="canceleditemp"> The main action returns canceleditemp to the framework to cause page navigation The actionlistener executes a Rollback operation before the main action Two actions, one component No Java! 55