Introduction to Oracle ADF Development


Options



Before You Begin

Purpose

This tutorial shows you how to build a rich Web application that interacts with a database. You'll be using Oracle JDeveloper 12c Version 12.2.1 and the Oracle ADF framework to build the application, and in the process you'll work with Oracle ADF Business Components, Oracle ADF Faces Rich Client Components and Oracle ADF Task Flows.

The tutorial takes you through a simple scenario of building a Web application that provides a user interface to access database tables. You use Oracle JDeveloper 12c Version 12.2.1 and Oracle ADF to create a complete application including business services, user interface and page flows. The focus of the tutorial is to illustrate the visual and declarative approach that Oracle ADF provides for Java EE application development. While working through the tutorial notice how ADF saves you from writing low level code and speeds up your development process.

What Do You Need

To complete this tutorial you must:

1: Have access to or have installed Oracle JDeveloper 12.2.1. You can download it from Oracle Technology Network. Install it into a directory of your choice, which, in this tutorial is referred to as JDEVELOPER_HOME.

2: Have access to, or have installed an Oracle database, including the HR schema. (Note that the schema may be locked for security purposes. If this is the case you will need to log in to SQLPlus using the system user, and unlock it). The image below shows you an example of the page you'll create..

Required Files
Download Files

The application that you create displays information about departments and employees. You create several JSF pages that enable you to query and update the data in the database. You also create a page that is used as a display container for several task flows. To see the completed application, click the Download button to download a zip of the completed application, and then unzip it in your JDeveloper mywork folder.

Download solution application

Step 1: Create a Fusion Web Application

When you work in JDeveloper, you organize your work in projects within an application. JDeveloper provides several template applications that you can use when creating an application and projects. The template applications are pre-configured with a basic set of technologies that are needed for developing the various types of applications. You create your working environment by selecting the template that best fits your needs and then configure it to add any additional technologies you plan to use.

In the first part of this tutorial you are going to create a new Fusion Web application and build reusable business components that will access the database. You'll be using Oracle ADF Business Components to map Java objects to existing tables in your database.

  1. Start JDeveloper by selecting Start > Programs > JDEVELOPER_HOME > OracleHome > Oracle JDeveloper Studio > Oracle JDeveloper Studio.

    If a dialog box opens asking if you would like to import preferences from a previous JDeveloper installation, click No.

  2. In the Select Role dialog, select Studio Developer (All Features) and click OK.

    This screenshot shows the role Studio Developer (All Features) in the list of available developer roles is selected by default.

    Shaping, which is based on the role of the user, allows the JDeveloper environment to tailor itself. It does this by removing unneeded items from the menus, preferences, new gallery, and even individual fields on dialogs.

    Shaping can even control the default values for fields on dialogs within the tool. When you first start JDeveloper, you are prompted to choose a role that describes how you are going to use JDeveloper. If you choose a role of "Java Developer" versus "Database Developer " versus "Customization Developer " you will get a totally different experience!

  3. If a dialog box opens asking if you would like to import preferences from a previous JDeveloper installation, click No.

    This screenshot shows the Yes and No buttons that give the option to import JDeveloper preferences from an existing installation.
  4. In the Track Usage popup, click OK.

    This screenshot shows a selected checkbox that enables automated usage tracking by default.
  5. Once loaded, the JDeveloper IDE appears. The very first time you open JDeveloper, the Start Page displays. You can re-invoke the Start Page later by choosing Help > Start Page.

    Notice the various options available to help you learn about JDeveloper. After exploring some of these options, close the Start Page by clicking the X on its tab (the X appears when you mouse over the tab).

    This screenshot displays various options to explore more about JDeveloper.
  6. Click the New Application link in the Applications window.

    This screenshot shows the Applications window with New Application selected by default and also displays the Open Application option.
  7. In the New Gallery, select ADF Fusion Web Application and click OK.

    This screenshot shows the New Gallery dialog that is divided into two panes, Categories on the left and Items on the right. The right pane displays the items for the selected category.
  8. JDeveloper loads the required features for a Fusion Web application and the Create Fusion Web Application (ADF) wizard launches. In the Name your application page of the wizard, type HRSystem as the name. If required, you can change the directory path to create your files in another location.

    In the Application Package Prefix field set the value to be demo and click Next.

    This screenshot displays the application name as specified in the previous praragraph. The directory name defaults to the application name entered and the directory path defaults to c:\JDeveloper\mywork, by default.
  9. In the Name your project page ensure that the project name is Model (the default). Notice that ADF Business Components and Java are listed as the project features of a Fusion Web application.

    Then click Next

    This screenshot displays the project name as specified in the previous praragraph. The project directory defaults to the project name within the application directory. This screen also displays the Project Features.
  10. The Configure Java settings page allows you to define a default package, a Java source path and an output directory. Click Next to accept the default values.

    This screenshot shows the default Java Settings. The source path and the output directory are created by default within the application directory.
  11. In the second Name your project page, ensure that the Project Name is ViewController. Scroll through the list of project features to see the types of technologies that can be used with a Fusion Web application.

    Click Next.

    This screenshot shows the project name as specified in the previous praragraph. The project directory defaults to the project name within the application directory. This screen also displays the Project Features.
  12. In the Configure Java settings page accept the defaults and click Finish to create your Fusion Web application and projects.

    This screenshot displays the default Java Settings. The source path and the output directory are created by default within the application directory.
  13. The HRSystem application and the two projects are displayed in the Applications window on the left of the screen. Save your work.

    Notice too, the Checklist on the right side of the screen. This checklist is displayed by default when a Fusion Web application is created. It is designed as a guide to lead you through the tasks involved in building this type of application. The next steps show you how the checklist might be used while developing an application.

    This screenshot shows the Applications window on the left and the Overview page of the selected application on the right. By default, it also shows the checklist that you need to accomplish to create a Fusion Web Application.

Step 2: Build the Business Services

In this section, connect to a database and build simple backend business components that access HR schema tables.

  1. In the CheckList Overview, click the Connect to a Database step.

    This screenshot shows the application overview page with a checklist on the right and the step-by-step instructions to build a Fusion Web Application, on the left.
  2. The step expands showing useful information such as prerequisites required for performing the task and detailed instructions on how to perform the task. Click the Create a Database Connection button.

    This screenshot shows an expanded Connect to a Database step. The expanded step details the prerequisites, step-by-step instructions on how to perform a task. It also displays the outcome of the performed task and link to the guide.
  3. Specify the properties for connecting to your HR schema.

    Enter the appropriate Oracle JDBC Settings to point to the right host, port and SID for your database. Click the Test Connection button to verify that you can connect successfully.

    Click OK to continue.

    This screenshot shows the properties page with credentials specified as mentioned in the previous paragrah to connect to the Oracle database. It also has the option to check if the connection is successful.
  4. Click the down arrow to shrink the Connect to a Database step.

    Then, in the Checklist, set the status of the Connect to a Database step to Done.

    This screenshot shows the statuses of the Connect to a Database task with Done as selected.
  5. Click the Build Business Services step to expand it, then click the Go to Substeps button.

    This screenshot shows an expanded step of the Build Business Services task that you need to perform. It also shows if this task involves multiple substeps.
  6. In the list of substeps, click the Create Entity Objects and Associations sub step.

    This screenshot shows the substeps that are involved in creating Business Services with Create Entity Objects and Associations step highlighted.
  7. In the Select Project for Action dialog, select the Model project and click OK.

    This screenshot shows the Model project selected for which you want to create entity objects. The Project drop-down lists all the projects that you have created for an application.
  8. The Create Business Components from Tables wizard launches. In the Entity Objects page, click the Query button to examine the data dictionary and see available tables.

    This screenshot shows the Create Business Components from Tables wizard where you can query a database schema to list the available tables.
  9. Select the EMPLOYEES, JOBS and DEPARTMENTS tables in the Available list, and click the right arrow to move your selections to the Selected list. This step creates updatable entity objects based on the tables selected.

    Then, click Next.

    This screenshot shows the tables as specified in the previous paragraph selected, from the list of available tables.
  10. In the Entity-based View Objects page of the wizard, move DepartmentsView (Departments), JobsView (Jobs) and EmployeesView (Employees) to the Selected list. This step creates matching view objects DepartmentsView, JobsView and EmployeesView for performing queries on the entity objects you just created.

    Then, click Next and then Next again.

    This screenshot shows the view objects as specified in the previous paragraph selected.
  11. In the Application Module page, click Finish to create the business components in the Model project.

    This screenshot shows the default name of the Application Module and Add to Application Module checkbox selected by default.
  12. In the Checklist, set the status of the Create Entity Objects and Associations step to Done.

    This screenshot shows the Create Entity Objects and Associations statuses with Done as selected.
  13. Click the Close Step 3 button..

    this screenshot shows the substeps of the Build Business Services and Close Step 3 button highlighted to collapse the substeps.
  14. Set the status of the Build Business Services step to Done

    Save all your work

    This screenshot shows the statuses of the Build Business Services task with Done as selected.
  15. In the Applications window right-click AppModule and select Run to invoke the application module tester. This starts a small Swing-based application that allows you to test the ADF Business Components you have just created.

    This screenshot shows the right-click menu of the Application Module with Run option selected.
  16. In the Oracle ADF Model Tester window, double-click the EmpDeptFkLink1 node to show the department and employees data. Navigate between the records using the Next button and notice the automatic master-detail synchronization.

    This screenshot shows the ADF Model Tester for the application module you ran. On the left, the screen displays different views of the application module and their links and the right pane shows the data for the selected link. You can navigate through the records by using the buttons.

    This screenshot shows the master-detail synched records during navigation.
  17. Click the Specify View Criteria (binocular icon) button in the master toolbar, to enter search criteria for your data.

    This screenshot highlights the Specify View Criteria icon that opens a View Criteria dialog.

    Specify 1700 in the LocationId field and click the Find button to execute the query.

    This screenshot shows the criterion as specified in the previous paragraph, entered. You can specify your criteria to find or remove the records from a table. You can also select from the predefined criteria.
  18. The form now only shows departments in this location. Use the Next button to scroll through the departments at Location 1700, including Purchasing.

    This screenshot shows the master-detail synched records based on the specified criteria.

    You need to remove the parameter value of the search criteria to access all departments again.

  19. Close the Oracle ADF Model Tester window, and back in JDeveloper, click the Save All icon on JDeveloper main toolbar. icon on the JDeveloper menu bar, or select File > Save All from the menu.

Step 3: Develop a JavaServer Faces page

JavaServer Faces (JSF) is a standard Java EE technology that simplifies Web development. In this part of the tutorial you 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.

Step 4: Test the page from a browser

In this section, you test the page as currently exists. If this is the first time you are running a page from inside JDeveloper, you must first let the integrated WebLogic Server install.

  1. This first step is to install the integrated WLS. If it is already installed, then you may go to step 3.

    From the Run Menu, select Start Server Instance.

    this screenshot shows the menu command in JDeveloper to start the integrated Web Logic Server.
  2. In the Create Default Domain popup, enter a value for the password and then confirm it.

    Then click OK.

    This screenshot shows the Create Default Domain dialog with the credentials for Web Logic Server entered.

    The Log window will show you when WLS has been installed and started.

    This screenshot highlights the message that the Integrated Web Logic Server has started. It also shows the time it took to start the Web Logic Server.
  3. Next, deploy the page to WLS

    Right click in the visual editor and from the menu, select Run.

    This screenshot shows the visual editor and the menu command to deploy the page to Web Logic Server.

    The Log window will show you the target URL when deployed.

    This screenshot shows the Log window that displays the Target URL.
  4. Your browser will display the page and the two columns - Id and Name. Also notice any of the data records can be selected. Nothing will happen when the record is selected. We'll take care of that in the next section.

    Keep the browser window open. Do not close it.

    This screenshot shows the browser window displaying the page that you are designing.

Step 5: Modify the layout of the page

In this section, you modify the page by adding some components to determine the layout of the page. First you add a dashboard to set the general layout of the page. Then you add components which will display synchronized data

  1. Go back to JDeveloper and in the Structure window, select the f:facet - center.

    This screenshot shows the Structure window that displays the attributes of a JSF papge with Center facet selected.
  2. Modify the layout of the header. In the Components Window, expand the Layout node and in the Interactive Containers and Headers section, notice the Panel Dashboard.

    This screenshot shows the Components window with Layout node expanded. The Layout node dispalys the layout components. Few Layout components are displayed under Interactive Containers and Headers section, where panelDashboard is highlighted.

    Drag it and drop it onto the f:facetCenter in the Structure window.

    This screenshot shows the Structure Window with panelDashboard placed under the Center facet.
  3. Next in the Components window, find another layout component, a Panel Box.

    This screenshot shows the Components window with panelBox selected under Layout node.

    Drag and drop it, in the Structure window, on the af:panelDashboard component your just added.

    This screenshot shows the Structure window with panelBox placed under panelDashboard.
  4. Add another 3 Panel Boxes to the af:panelDashboard so that you have four in total.

    This screenshot shows the Structure window with four panel boxes placed under panelDashboard.
  5. Set a property for all the panel boxes. In the Structure window, select all the af:panelBoxes.

    Then in the Properties window, set the Appearance > ShowDisclosure to false.

    Save your work

    This screenshot shows the Structure window with all Panel Boxes selected and the Properties window of the Panel Boxes, where Appearance section is expanded.
  6. Back in the Structure window, select the af:panelDashboard.

    Then set the Columns to 2 and RowHeight to 350px.

    Save All your work

    This scresnshot shows the Structure window with panelDashboard selected and the properties windows of panelDashboard where Common section is expanded. The Columns and RowHeight attributes are highlighted.
  7. Go back to your browser and reload the page to see the panel boxes.

    This screenshot shows the reloaded browser page that displays the data on the left side with all the inserted panel boxes on the right side.

Step 6: Refine the dashboard and display data

In this part of the tutorial, you enhance the user interface by adding a table of employees and including the ability to do column selection, by reordering the fields in one of the panels, and by binding the business components to a chart . You do this with simple drag and drop operations - behind the scenes the ADF Model layer handles the data binding for you.

  1. Back in the Structure window of JDeveloper, select the af:panelBox - PanelBox1.

    Set the Text property to Employees. Save your work.

    This screenshot shows the Structure window with the first Panel Box selected and also the Properties window of the Panel Box. The Properties window displays the expanded Common section with the text modified.
  2. Next, add some data from the Data Controls window.

    Expand the AppModuleDataControl > DepartmentView1 nodes to expose EmployeesView4. Note that these are the "detail" employees for the "master" departments - they are linked and therefore at runtime, the employees you see in this view object are the ones who belong to the selected (or viewable) department.

    Drag the EmployeesView4 onto the Structure window and drop it on the af:panelBox - Employees node. In the popup menu, select Table/List View > ADF Table.

    This screenshot shows two windows and a popup menu. The first is the Data Controls window where a data control is dragged and dropped to the first Panel Box of the Structure window, which is the second window. When dropped, a popup menu displays from where the Table/ListView - ADF Table layout for the panel box is selected.
  3. In the Create Table pane, allow for Single Row selection.

    Enable Sorting, Filtering and set the table to be Read-Only.

    Delete all the columns except FirstName, LastName and Email. Then click OK.

    This screenshot shows the Create Table pane where the specific attributes as mentioned in the above paragraph are selected.
  4. Save all your work

    Since you've added new data to the page, it must be deployed again. Right click on the page and select Run. This will compile your project, build it, and launch the integrated WebLogic Server to run it. The default web browser opens to display the page. You can follow the progress of these steps in the Log window in JDeveloper.

    This screenshot shows the visual editor in the background and the menu command to deploy the page to Web Logic Server.
  5. Now you see employee records in the first panel.

    By default the first department's (Administration) employees populate the panel.

    This screenshot shows a browser page that displays the data on the left side and all the panel boxes on the right side. The first panel box displays the data as added in the previous steps in a tabular format.

    Click an different department and the employee records automatically update.

    This screenshot shows the browser page that displays a different data selected on the left side and the first panel box displaying the corresponding data and the other panel boxes on the right side.
  6. Select the Shipping department.

    Then, move the mouse over the FirstName heading to reveal two sorting icons. Move the mouse over the upward triangle and a Sort Ascending tool-tip displays.

    You may sort on any item by selecting the ascending or descending icons.

    This screenshot shows the browser page with different data selected on the left side and the first panel box displayng the corresponding data and other empty panel boxes on the right side. The first column in the first panel box displays the two sorting icons.

  7. Click and hold the LastName column prompt. Then, drag it to the left and reposition it before the FirstName column.

    This screenshot shows the browser page that displays how to rearrange the columns in the first panel box by drag and drop.

    This screenshot shows the browser page that shows the rearranged columns in the first panel box.
  8. Place the cursor in the field above the LastName column. Then, type "M" and press the Enter key to filer only those employees who's last name begins with "M"

    This screenshot shows the browser page where the data in the first panel box is filtered by the specified criterion.
  9. Back in JDeveloper, lets work on the second panel box.

    Select the second panel box and set the Text property to Details.

    This screenshot shows the Structure window with the second panel box selected and the corresponding Properties window. The Common section of the Properties window is expanded with the Text attribute modified as specified in the paragraph above.
  10. From the Data Control window, drag the same EmployeesView4 collection, as you did earlier, and drop it on the Details panel box.

    In the popup menu, select ADF Form.

    This screenshot shows the Data Controls window where a data control is dragged and dropped to the second Panel Box of the Structure window. When dropped, a popup menu displays from where the Form layout for the second panel box is selected.
  11. In the Create Form pane, keep the FirstName, LastName, Email, PhoneNumber, HireDate, JobId and Salary and remove the rest of the fields.

    Then click OK and Save your work.

    This screenshot shows the Create Form pane where the specific attributes as mentioned in the above paragraph are selected.
  12. You can click the recompile button, just below the menu bar of JDeveloper, to move these changes forward .

    This screenshot shows the JDeveloper toolbar that highlights the recompile button.

    Then, reload the browser page to see the second panel contains detail data of the selected employee.

    This screenshot shows the reloaded browser page that displays data in the left pane, first, and second panel boxes. The second panel box displays the data as included in the previous steps in a form format.
  13. Select a different employee and notice how the detail refresh with new values for the selected employee.

    This screenshot shows the browser page with different details in the second panel box when a different record is selected in the first panel box.
  14. If you input an invalid value for the date filed, you automatically receive an error.

    This screenshot shows the browser page that displays an error message when an invalid value is entered in one of the fields in second panel box. The error message also displays the valid format.

    You also get a calendar icon, to the right of the field, to pick the correct date.

    This screenshot displays the browser page that displays a Calendar icon for the field that has the datatype as Date.
  15. Next let's work on the third box. Select it and set the Text property to Salaries.

    This screenshot shows the Structure window with the thirds panel box selected and the corresponding Properties window. The Common section of the Properties window is expanded with the Text attribute modified as specified in the praragraph above.
  16. From the Data Controls, drag the EmployeesView4 to the Structure window and drop it on the Salaries panel box.

    In the popup menu, select Chart....

    this screenshot shows the Data Controls panel from where a data control is dragged and dropped to the third panel box, and a Chart layout is selected from the popup menu.
  17. When creating a chart, the same data control can be used to make a variety of different charts.

    For our purposes, select the Bar category, ensure the Chart Type is set to Bar and use the second Quick Start Layout.

    Then click OK.

    This screenshot shows the Component Gallery. The left pane shows the Categories pane that lists different chart categories. When a category is selected, the top center pane displays the Chart Types and the top right pane displays the description. The bottom pane displays the corresponding Quick Start Layouts for the selected chart type. In this screenshot, Bar is selected under Categories and Bar is selected under Chart Types.
  18. Once you decide on a chart, you then you determine the bars and X axis fields to use.

    From the Available column, drag the Salary to the Bars field and drop it. Then, drag the LastName to the X Axis and drop it.

    Then click OK.

    This screenshot shows the Create Bar Chart window where you can drag and drop the fields for x and y axis. In this screenshot, Salary is dropped for Bars and Lastname is dropped for X azis. A sample chart is also displayed.
  19. Like earlier, Save your work, recompile and reload the browser to see the changes.

    This screenshot shows the JDeveloper toolbar with recompile button highlighted to recompile the page.

    Now the Salaries panel shows all the employees in a department and their salaries.

    This screenshot shows the browser page where a table is displayed in the first panel box, corresponding details in a form layout in the second panel box, and a chart in the third panel box.
  20. If you remove the filter in the Employees panel box, then the bar chart updates to include all the shipping employees salaries.

    This screeshot shows the browser page without any filters.
  21. Next, modify the chart.

    Select the dvt:barChart and then in the Properties, put the cursor next to the magnifying glass and enter Zoom. This allows you to filter and find properties easier

    The ZoomAndScroll property should be shown. Change the value to live.

    Save your work.

    This screenshot shows the Structure window with the barChart selected in the third panel box and the corresponding Properties window and displays the ZoomAndScroll property.
  22. Recompile the application and then reload the browser.

    In the Shipping department, with no filter on the Employees, there are many salaries to show and you are not able to see all the names.

    Place the cursor over the X axis and you get a cross hair cursor. Drag the cursor to highlight a portion of the chart (The highlighted portion is a lighter shade). Then release the cursor.

    This screenshot shows the browser page that displays only the third panel box with a portion of the chart highlighted.

    When you release the mouse, the selected records zoom to fill the whole panel box and you have a scrolling bar on the bottom to see all the other records that are hidden from view.

    This screenshot shows the browser page that displays only the third panel box with the portion of chart that was highlighted earlier, zoomed in and other records hidden.

    Scroll the bar to the left to see the other employee salaries.

    This screenshot shows the browser page that displays only the third panel as in the previous image and scrolled to left to view other records that were hidden from the view earlier.

Step 7: Fine tune Model components to refine how the data displays

In this part of the tutorial, you refine the employee business components, add validation and modify how the UI displays.

  1. In the Applications window, expand the Model > Application Sources > demo.model and double-click the Employees entity node.

    The full definition opens in the editor area. Select the Attributes tab to see all the employee attributes.

    This screenshot shows the Applications window with the Model project expanded and the Employees entity selected on the left side of the window. On the right, the screenshot displays the editor area, the Attributes tab selected, and displays all the employees attributes.
  2. Select the Salary attribute then click the Validation tab below.

    To the right-click the green plus sign to add a new validation rule.

    This screenshot shows the employees attributes in the editor area, the Salary attribute selected in the top pane, Validatation Rules tab selected in the bottom pane, and the add new validatation icon selected.
  3. Set the Name to SalaryRange, the Type to Range, the Minimum Value to 0 and the Maximum Value to 50000.

    There are many operator you could you to implement your validations including, compare, length, restrictive list and others.

    This screenshot shows the Add Validation Rule for the selected attribute, where you can specify the validation rule as mentioned in the previous paragraph.
  4. Click the Failure Handling tab and then set the error message text.

    Set the Message Text property to The Salary is out of range (must be between 0-50k).

    This screensot shows the Add Validation Rule for the selected attribute, the Failure Handling tab selected, and the Message Text property entered.
  5. Save All your work.

  6. Next, refine the display properties of the HireDate.

    Select the HireDate attribute and then click the UI Hints tab.

    Set the Label to Hired On, the Format Type to Simple Format, and then select a Format you like.

    This screenshot shows the editor area with employees attributes, HireDate attribute selected in the top pane, UI Hints tab selected in the bottom pane, and few fields entered with the details as mentioned in the previous paragraph.
  7. Save all your work and then click the x in the Employees.xml tab.

    This screenshot shows the editor area and highlights the close button of the Employees.xml tab.
  8. Next, in the Applications window, double-click the EmployeesView component.

    In the editor, select the Attribute tab, and then the JobId.

    Click the List of Values tab and then click the green plus sign.

    This screenshot shows the Applications window and the editor area. On the left, this screenshot displays the Applications window with expanded Model project and EmployeesView component selected. On the right, displays the editor area of the EmployeesView.xml. The editor area is divided into three parts. On the left pane, Attributes tab selected, on the top right pane, JobID attribute selected, and in bottom right pane, List of Values and create new list of values icon selected.
  9. In the Create List of Values pane, set the Name to JobsLOV.

    Then in the List Data Source, click the green plus sign and select the JobsView.

    Click Ok to return.

    This screenshot shows the Create List of Values dialog with all the other values selected as specified in the previous paragraph and the View Accessors dialog.

    Back in the LOV pane, set the List Attribute to JobId .

    This screenshot shows the Create List of Values dialog with List Attribute under Configuration tab set to JobId.
  10. Now set the UI Hints for the LOV.

    Click the UI Hints tab and shuttle the JobTitle to the Selected side to display it in the LOV.

    At the bottom of the pane, you can set a limit for the number of records to retrieve. Deselect the Query Limit to remove that restriction.

    Then click OK to complete the LOV.

    Save all your work

    This screenshot shows the Create List of Values dialog with UI Hints tab selected. The UI Hints tab list the available attributes on the right under Available and when selected, shows the attributes on the left under Selected. The Query Limit in the bottom pane is highlighted.
  11. Now update the page to reflect the newly added JobId LOV.

    Go back to the HR.jsf page and in the Structure window, expand the af:panelBox - Details > af:panelFormLayout.

    Select and delete the af:inputText - JobId.

    This screenshot shows the Structure window of the jsf page with inputText - JobID selected as specified in the previous paragraph.
  12. Now using the Data Controls, add the JobId back to the page (which will bring along the LOV). The key thing to remember is the attribute you add must come from the same data control as it did originally (in our case EmployeesView4).

    Open the Data Controls window and expand the AppModuleDataControl > DepartmentView1 > EmployeesView4 and select the JobId.

    Drag and drop it between the HireDate and Salary.

    In the popup menu select List of Values > ADF LOV Choice List.

    This screenshot shows the Data Controls window and the Structure window. JobId data control from the Data Control window is dragged and dropped to the Structure window under the panelFromLayout, which was selected in the previous step. The screenshot also shows the List of Values  - ADF LOV Choice List selected from the popup menu.

    If the af:inputComboboxListOfValues is not positioned correctly, drag it to the correct place.

    Save all your work.

    This screenshot shows the Structure window with inputComboboxListOfValues selected, which was added in the previous step.
  13. The last thing we need to do is add commit and rollback functionality.

    In the Data Controls, expand the AppModuleDataControl > Operations nodes.

    Drag the Commit operation to the Structure window and drop it on the f:facet - appNav node.

    In the popup menu select ADF Link.

    This screenshot shows the Commit operation from the Data Controls window is dragged and dropped to the appNav facet in the Structure window as ADF Link.

    Then, using the same gestures, add a Rollback right below it

    This screenshot shows the Structure window with the Rollback operations added to the appNav facet as ADF Link.

    To finish this step add a Spacer (from the Components window) between the two links. Use the search area at the top of the window to find the Spacer component.

    This screenshot shows the Structure window ont he left and the Components window on the right that displays the Spacer component. The Structure window also displays a Spacer component added between the Commit and Rollback operations.
  14. Save your work and compile the changes. Since we added new validation, right-click in the HR.jsf page and select Run.

    When the browser opens, navigate to the Details panel box, click the widget next to the JobId and notice the drop down displaying all the job names. Change the job to a different value.

    Also notice the label and format for the HireDate field match what we set earlier.

    This screenshot shows the browser page that displays the data on the left pane, all the four panel boxes on the right pane. In the Details panel box, the Hired on field is highlighted. The JobId field displays a list of values.

Step 8: Use the ADF Controller to determine relationships between screens

Web applications usually have more than one page in them. In this part of the tutorial you two pages - a Job Search page, and an Edit page - to your application and use the ADF Task Flow Diagrammer to define the navigation rules between the two pages. You then use features of the ADF Faces Framework to add extra functionality to the pages. Finally you add the task flow to one of the panels on the page.

In this section, you work with the ViewController project and include task flows to determine business processes. You create a new task flow, add view components and control flows and then consume the task flow in the HR page.

  1. In the Applications window, right-click the ViewController and select New > ADF Task Flow....

    This screenshot shows the Applications window with the ViewController project selected and the menu item selected as mentioned in the previous paragraph.
  2. In the Create Task Flow pane, set the File Name to JobSearch.xml. The remaining values should be fine, confirm the Create as Bounded Task Flow and Create with Page Fragments checkboxes are selected.

    Then click OK.

    This screenshot shows the Create Task Flow pane with File Name filled and other fields highlighted as mentioned in the previous paragraph.
  3. The task flow opens in the editor. Notice the Components window now shows activities and control flows you may add. You may call a method or another task flow, invoke routers or return to called task flows. We'll keep it simple and add a couple of pages, with a control flow between them.

    From the Components window, drag a View activity onto the editor and drop it. Set the name to search. The green circle surrounding the view signifies it is the entry point to the task flow.

    This screenshot shows that the View activity from the Components window is dragged and dropped to the e editor the name modified as specified in the previous paragraph.

    Add another View activity, to the right, and name it edit.

    This screenshot shows another View activity dragged from Components window and dropped to editor and modified as specified in the previous paragraph.
  4. Next, from the Components window, drag a Control Flow Case and drop it on the search view activity as the starting point. Then click on the edit view activity as the ending point.

    Name the flow edit.

    This screenshot shows a Control Flow Case dragged from the Component window and dropped to the editor and modified as specified in the previous paragraoh.

    Add another flow starting with the edit going back to search. Name it back.

    Save all your work

    This screenshot shows another Control Flow case dragged and dropped and modified as specified in the previous paragraph.
  5. Next, define the search page. This page will let you search for jobs and then move on to update properties about the job

    Double click the search view to create the page.

    The name is carried over to the Create a new ADF Page Fragment pane. Make sure the Create Blank Page radio button is selected and then click OK.

    This screenshot shows the Create ADF Page Fragment where Create Blank Page is selected.
  6. Expand the Data Controls > AppModuleDataControl > JobView1 > Named Criteria and select the All Queryable Attributes.

    Drag the All Queryable Attributes onto the editor and drop it near the top left of the page. A the popup menu will appear. Select Quick Query > ADF Quick Query Table...

    This screenshot shows the Data Controls window from where All Queriable Attributes is draagged and dropped to the Search page and Quick Query - ADF Quick Query Table is selected from the popup menu.
  7. In the Create Table pane, set the Row Selection to Single Row and select both Enable Sorting and Enable Filtering check boxes.

    Then click OK.

    This screenshot shows the Create Table pane with the values selected as specified in the previous paragraph.

    The Structure pane and editor area should look like the following image.

    This screenshot shows panelGroupLayout selected in the Structure window and the Jobs table in the editor area.

    Save all your work

  8. Make a change to the JobId and convert it to a different component.

    In the editor, right-click the JobId outputText and from the menu, select Convert To...

    This screenshot shows the Convert To selected from the righ-click menu of JobId.

    In the Convert Output Text pane, scroll down and select Link. Then click OK.

    This screenshot shows the Link option selected in the Convert Output Text dialog.

    In Confirm Convert pane, ensure Value is selected and then click OK.

    This screenshot shows the Value option selected in the Confirm Convert dialog.
  9. Next, set a couple of properties for the link.

    In the Structure window or in the editor, select the link. Then in the Properties window, set the Text property to Select and then, using the dropdown, set the Action property to edit.

    Save your work.

    This screenshot shows the Link option selected in the Structure window and Common and Link section expanded in the Properties window. The Text and the Action properties are modified as specified in the paragraph above.
  10. Next, create the edit page.

    Go back to the JobSearch task flow and double-click the edit view.

    This screenshot shows the editor with the edit activity selected.

    The values in the create page should be fine. Check that yours look like the image below. Then click OK.

    This screenshot shows the Create ADF Page Fragment with default values.
  11. From the Data Controls window, drag the JobView1 collection and drop it on the edit page.

    In the popup menu, select ADF Form.

    This screenshot shows the Data Controls page from where JobsView1 is dragged and dropped to the Edit page and ADF Form selected from the popup menu.
  12. In the Create Form pane, select the Submit check box.

    Then click OK.

    This screenshot shows the Create Form page with Submit checkbox selected.

    The Structure window and editor should look like the image below.

    This screenshot shows the panelFormLayout selected in the Structure window and the Jobs table in Form layout with Submit button in the editor area.
  13. Next, modify some properties to commit changes.

    First find and select the Submit button. Change the Text property to Save and Action to back.

    This screenshot shows the Submit button selected in the Structure window. It also shows the Properties window with Save specified in the Text field and back selected in the Action field.
  14. Next, add the commit functionality.

    In the Data Controls window, expand the Operations node. Select the Commit operation and drag, then drop it on the Save button.

    This screenshot shows the Data Controls window with the Commit operation selected and dropped to the Edit page.

    In the popup pane, select properties that should remain at their current values. The unselected properties will be updated to new values.

    Select the text, disabled and action properties.

    Then click OK and Save all your work.

    This screenshot shows the Confirm Component Rebinding dialog where the fields are selected as mentioned in the paragraph above.
  15. Now, lets work on the final panel box in the HR page.

    Open the HR page in the editor and select the af:panelBox - PanelBox4.

    Set the Text property to Job Search.

    This screenshot shows the fourth panel box selected in the Structure window and the corresponding Properties window where the Text field is modified as specified in the paragraph above.
  16. In the Applications window, expand the ViewController > Web Content > Page Flows nodes and select the JobSearch task flow.

    Drag the JobSearch page flow onto the HR page and drop it on the Job Search panel box.

    In the popup menu, select Region.

    This screenshot shows the Applications window from where the JobSearch under page flow is dragged and droped to the fourth panel box. The fourth panel box shows a popup menu where Region is selected.

    The Structure window should display the region, nested in the Job Search panel box. If it is not, move so it is.

    This screenshot shows the region nested under JobSearch panel box in the Structure window.
  17. Save your work

    Then, right-click the HR page and select Run.

    This screenshot shows the visual editor in the background and the menu command with Run selected to deploy the page to Web Logic Server.
  18. When the page opens, move the cursor to the Job Search panel box.

    Set the Search property to JobTitle and then enter M in the search box. Then press Enter.

    All the job titles that begin with M are displayed.

    This screenshot shows the browser page with the search criteria as specified in the paragraph above, entered in the fourth panel. The data displayed in the fourth panel corresponds the search criteria entered.
  19. Next, test the edit page. Click the Select text for one of the jobs .

    This screenshot shows the fourth panel with one of the JobId selected.

    This link will use the edit flow and navigate you to the edit page.

    This screenshot shows the Job Search edit page for the record that was selected in the previous step.
  20. Set the Min Salary to 10000 and click Save.

    This screenshot shows the edit page with the changes as specified in the paragraph above and the Save button.

    You will return to the search page, with the new minimum salary displayed.

    This screenshot shows the Search page (fourth panel) with the changes done in the previous step.
  21. As a final task, .

    In the Component window, expand the Operations node and scroll down to the Drag and Drop section.

    Select the Component Drag Source. Then drag it to the Structure window and drop it on the Employees panel box.

    This screenshot shows the Structure window with the componentDragSource component under the Employees panel box. This screenshot also shows the Components window with the expanded Oeprations node from where the component is dragged.

    Repeat the same process and add Component Drag Source components to each of the remaining panel boxes. Each of the four panel boxes should have their own drag component.

    This screenshot shows the Structure window with the componentDragSource component added to all the four panle boxes.
  22. Save your work.

    Then, right-click the HR page and select Run.

    This screenshot shows the visual editor in the background and the menu command with Run highlighted.
  23. In the running page, notice the handle icon at the top and center of the panel box.

    This screenshot shows the browser page with a handle icon at the top of the panel boxes.

    With your mouse, select and hold one of the handles. Then move it to a different place on the page and release.

    This screenshot shows the browser page with panel boxes being rearranged with the help of the handle icon.

    The new location of the panel box remains until the page is reloaded.

    This screenshot shows the browser page with the rearranged panel boxes.

Congratulations the tutorial is now complete.