Monday, 30 April 2018

Step 3: Develop a JavaServer Faces page

JavaServer Faces (JSF) is a standard Java EE technology that simplifies Web development. You can create a JSF page to access the business components that you created in the previous part.
You create a form that can be used to display and modify data. You use a master-detail relationship to display information about employees in a department. To build the page you'll use Oracle ADF Faces Rich Client components. These components allow you to build an Ajax-based rich Web UI without writing low-level HTML and Javascript code.
In this step, develop a page
  1. Right-click the ViewController project node in the Applications window, and select New > Page...
    This screenshot shows the Applications window and the right-click menu with New - Page selected, which is the web part (user interface) of the application.
    The Web part of the application is developed in a separate project called the ViewController project, which you created in the previous part of this tutorial when you created the Fusion Web application.
    Maintaining a separation between the Model layer and the user interface by developing them in separate projects, makes the business services layer more reusable.
  2. In the Create JSF Page pane, set the File Name to HR.jsf and ensure the Document Type is set to Facelets.
    Then to start building the page with a temple, select the Reference ADF Page Template radio button.
    In the Templates column, select the Tablet First Template and then click OK.
    This screenshot shows the Create JSF Page with the File Name entered and the fields highlighted as specified in the previous paragraph. You can create a page from a blank page or from existing templates, which are displayed on the left side of the dialog. The center pane displays the template style and the right side displays the description of the template.
  3. By default, the center of the IDE displays the page in a visual editor.
    On the lower left, the page is displayed in a structured format.
    The properties for any selected item can be modified in the lower right.
    This screenshot shows the jsf page in JDeveloper as described in the previous paragraph.
  4. In the Structure window, expand the f:view > af:document - HR,jsf > af:form and select the af:pageTemplate.
    In the Properties window, set the endWidth to 0px.
    This screenshot shows the Structure window with af:pageTemplate selected and the corresponding properties page. The Structure window displays different Template facets that can be added to a page.
  5. Use the Data Controls window to add data to the page.
    If you expand the Data Controls window, you can see the business services that are available while developing the page.
    Notice the names match those from the view components you created in the Model project.
    This screenshot shows the Data Controls window that lists the business services you added. You can add these data controls to a page.
    If you expand a node you see the collections, attributes and operations.
    This screenshot shows the expanded data control node of DepartmentsView1 that lists the collections, attributes, and operations for a node.
  6. In the Structure window, select expand the Template facets node. This is where the data will be displayed on the page. The Data Controls allow you to consume the model components and bind them to the page.
    Then, from the Data Controls window, select the DepartmentsView1 node. Drag it onto the Structure window and drop it on the start facet.
    From the popup menu, select Table/ListView > ADF List View...
    This screenshot shows the drag and drop option of a data control DepartmentsView1 to template facets Start. This screenshot also shows the popup menu with the menu selected as specified in the previous paragraph.
  7. For the layout, select the second option: Panel Grid Layout. Then, click Next.
    This screenshot shows the various options available to configure ADF List View with Panel Grid Layout selected.
  8. Set the grid layout to use two columns and one row. As you change the value on the left, the image on the right reflects how the page will look.
    Click Next.
    This screenshot shows the options available to configure a Panel grid layout. The Columns and Rows fields entered as specified in the previous paragraph. You can configure the number of columns, rows, and margins ans see the preview of the changes in the Preview pane.
  9. Set Column 1 to use 20% of the space and Column 2 to use 80%. Then click Next.
    This screenshot shows the fields filled with values as specified in the previous paragraph. You can see the preview of the changes in the Preview pane.
  10. Set the first column to display DepartmentId and the second to display DepartmentName.
    Then click Finish and save your work.
    This screenshot highlights the fields that are selected as specified in the previous paragraph. You can configure the display label for the selected fields and also see the preview.
  11. In the Structure window expand the nodes from the screen shot below to see the list view, the grid layout, the two columns (20% & 80%) and the Id and Name.
    This screenshot shows the Structure window that is expanded to display the listView and the panelGridLayout that was configured in the previous steps.
  12. Select the af:listView in the Structure window and then in the Properties window, set the Selection to single.
    This screenshot displays the Structure window with af:listView selected and the corresponding Properties window where you can set the properties.
  13. Then, expand the Behavior node and place the cursor in the SelectionListener property.
    A blue gear icon will appear at the end of the line. If you hover above it with the mouse a Property Menu tool-tip will display
    Here you can select from a list of built-in operations to work with the data controls.
    This screenshot shows the Properties window that lists the properties of a selected item. This screenshot displays the Behavior node expanded.
    Click the blue gear icon and from the menu,select Method Expression Builder...
    This screenshot shows the SelectionListener Property menu that lists the built-in operations. You can select an operation from the list to work with data control.
  14. In the Method Expression Builder, expand the ADF Bindings > bindings > DepartmentsView1 > treeModel nodes and select makeCurrent.
    Then click OK and then save all your work.
    This screenshot shows the Method Expression Builder dialog where you can select a method to build an expression. This screenshot shows an example of creating an expression for ADF Bindings.