Adding ADF Faces components to JSF pages
Now, for the magic to happen from the Business Service Layer to the view layer, in order to place the data, you can select the data that you want to insert from the Data Control and drag-and-drop it onto our page and choose the format that this page should have. So let's do that.
What we want is to have a form that has all employees' information inside our page.
How to do it…
Let's see how to add ADF Faces components to JSF pages:
- Expand HrAppModuleDataControl under Data Controls and drag
Employees1
into the white square inside of theemployees.jsf
page. Remember this is the view object that contains all employees' information, and it's based on theEmployees
Entity object. - Choose ADF Form... when the drag-and-drop dialog appears as shown in the following screenshot:
Now, a new dialog pops up asking you what you want to display in your form.
- Check the Row Navigation checkbox.
This will place all navigation buttons such as First, Next, Previous, and Last under the form.
- Click on OK to close the dialog.
- Open the HelloADFFaces Overview tab and check the Add Common Components checklist item as done.
How it works…
You can notice that, inside the form's input, you have something like #{bindings.FirstName.inputValue}
. This Expression Language (EL) expression represents the binding that gets created automatically once you have dragged-and-dropped the view object onto the page, which is a proof of the ADF Binding layer in action.
You can see these bindings by navigating to the Bindings and Executables tab, which will open the Page Data Binding Definition of the employees.jsf
page, which looks like the following screenshot:
You can see that FirstName
is under the Bindings section, and FirstName
is pointing to something called Employees1Iterator
under the Executables section. The Executables section is pointing to Employees1
, which is the child of HrAppModuleDataControl
under the Data Control section.
The Bindings and Executables sections are very important to understand since the whole ADF Binding mechanism is based on them. The Executables section represents activities that get executed when the page is ready to be viewed. So, Employees1Iterator
is getting executed to get all the data from the Employees1
view object, and the data will be available inside the Employees1Iterator
object. Thats why, when you click on it, you will get to edit some properties like how often this iterator should get refreshed, should the result get cached, and more features such as these.
As for the Bindings section, they are bound to those results data, and to items that can be referenced by components in your JSF page such as input Texts and Buttons. Also if you check the last four bindings, you will find them corresponding to four buttons in the page. These are actual actions that manipulate the data inside the iterator, which by definition manipulates the data in the view object as well. You can also see all these actions from the Data Controls pallet directly by expanding the view object, and you will find a folder called Operations
; expanding it will reveal all the operations you can have for this view object, which covers the main CRUD (Create Retrieve Update Delete) operations plus a few other operations. You also have two operations that are not related to a specific view object but related to the whole Data Control, and these are Commit and Rollback (To commit to database or roll-back changes).
The Page Definition is an XML file that is linked to the employees.jsf
page. This link is the one that makes Bindings available to the employees.jsf
page's EL as part of the ADF Faces lifecycle. The link between the page and Page Definition happens in a specific file called DataBindings.cpx
, which is also an XML file that has all pages and their corresponding Page Definitions.
Tip
To learn more about ADF Model and ADF Binding layer, check the official documentation at http://docs.oracle.com/middleware/1212/adf/ADFFD/bcdcpal.htm#BABHJJHA.
Now that you have finished creating the form inside the page, it is time to see everything in action and run your application.