oracle 11g jdeveloper rich web

99
Developing Rich Web Applications With Oracle ADF This tutorial shows you how to build a rich Web application that interacts with a database. You'll be using Oracle JDeveloper 11g Version 11.1.2 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. Purpose Duration Application The application that you create displays information on departments and employees. You create several JSF pages that enable you to query and update the data in the database. To see the complete application you will create, click the Download button to download a zip of the final application, and then unzip it in your JDeveloper mywork folder. 2 hours Part 1: Creating a Fusion Web Application and Building the Business Service 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, and you create your working environment by selecting the template that best fits your needs. You can then configure it to add any other 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 the Oracle ADF Business Components technology to map Java objects to existing tables in your database. Step 1: Create a Fusion Web Application Start JDeveloper by selecting Start > Programs > Oracle Fusion Middleware 11.1.2.0.0 > JDeveloper Studio 11.1.2.0.0 1. In the Select Role dialog, choose Studio Developer and click OK. 2. Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2... 1 de 18 23/04/2013 12:57 p.m.

Upload: rosmery-cardenas

Post on 08-Nov-2015

44 views

Category:

Documents


2 download

TRANSCRIPT

  • Developing Rich Web Applications With Oracle ADF

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

    Purpose Duration Application

    The application that you create displays information on departments and employees.You create several JSF pages that enable you to query and update the data in thedatabase.To see the complete application you will create, click the Download button todownload a zip of the final application, and then unzip it in your JDeveloper myworkfolder.

    2 hours

    Part 1: Creating a Fusion Web Application and Building the Business Service

    When you work in JDeveloper, you organize your work in projects within an application. JDeveloper provides several templateapplications that you can use when creating an application and projects. The template applications are pre-configured with a basic setof technologies that are needed for developing the various types of applications, and you create your working environment by selectingthe template that best fits your needs. You can then configure it to add any other 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 willaccess the database.You'll be using the Oracle ADF Business Components technology to map Java objects to existing tables in your database.

    Step 1: Create a Fusion Web Application

    Start JDeveloper by selecting Start > Programs > Oracle Fusion Middleware 11.1.2.0.0 > JDeveloper Studio 11.1.2.0.01.

    In the Select Role dialog, choose Studio Developer and click OK.2.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    1 de 18 23/04/2013 12:57 p.m.

  • If a dialog box opens asking if you would like to import preferences from a previous JDeveloper installation, click NO. Close theTip of the Day window.

    Once loaded, the JDeveloper IDE appears. The very first time you open JDeveloper, the Start Page displays. You can re-invokethe 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 StartPage by clicking the X on its tab (the X appears when you mouse over the tab).

    3.

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

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    2 de 18 23/04/2013 12:57 p.m.

  • Click the New Application link in the Application Navigator.4.

    In the New Gallery, choose Fusion Web Application (ADF) and click OK.5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    3 de 18 23/04/2013 12:57 p.m.

  • JDeveloper loads the required features for a Fusion Web application and the Create Fusion Web Application (ADF) wizardlaunches.In the Name your application page of the wizard, type HRSystem as the name. If required, you can change the directory path tocreate your files in another location.In the Application Package Prefix field set the value to be demo and click Next.

    6.

    In the Name your project page ensure that the project name is Model (the default). Notice that ADF Business Components andJava are listed as the project features of a Fusion Web application.

    7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    4 de 18 23/04/2013 12:57 p.m.

  • Click Next.

    The Configure Java settings page allows you to define a default package, a Java source path and an output directory. Click Nextto accept the default values.

    8.

    In the second Name your project page, ensure that the Project Name is ViewController. Scroll through the list of projectfeatures to see the types of technologies that can be used with a Fusion Web application.

    9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    5 de 18 23/04/2013 12:57 p.m.

  • Click Next.

    In the Configure Java settings page accept the defaults and click Finish to create your Fusion Web application and projects.10.

    The HRSystem application and the two projects are displayed in the Application Navigator on the left of the screen.11.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    6 de 18 23/04/2013 12:57 p.m.

  • Step 2: Build the Business Service

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

    The step expands showing useful information such as prerequisites required for performing the task and detailed instructions onhow to perform the task. Click the Create a Database Connection button.

    2.

    Notice too the Checklist on the right side of the screen.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    7 de 18 23/04/2013 12:57 p.m.

  • Specify the following properties for the new connection you are creating:

    Connection Name HRConn

    UserName hr

    Password hr

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

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    8 de 18 23/04/2013 12:57 p.m.

  • Click OK.

    Click the down arrow to shrink the Connect to a Database step.4.

    In the Checklist, set the status of the Connect to a Database step to Done.5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    9 de 18 23/04/2013 12:57 p.m.

  • Click the Build Business Services step to expand it, then click the Go to Substeps button.6.

    In the list of substeps, click the Create Entity Objects and Associations substep.7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    10 de 18 23/04/2013 12:57 p.m.

  • Click the Create Entity Objects and Associations button.8.

    In the Select Project for Action dialog, select the Model project and click OK.9.

    In the Initialize Business Components Project dialog select the HRConn connection if it is not already selected. Click OK.10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    11 de 18 23/04/2013 12:57 p.m.

  • The Create Business Components from Tables wizard launches. In the Entity Objects page, click the Query button to examinethe data dictionary and see available tables.

    11.

    Select the DEPARTMENTS and EMPLOYEES tables in the Available list, and click the right arrow to move your selections to theSelected list. This step creates updatable entity objects based on the tables selected.

    12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    12 de 18 23/04/2013 12:57 p.m.

  • Click Next to continue.

    In the Entity-based View Objects page of the wizard, move Departments (HR.DEPARTMENTS) and Employees(HR.EMPLOYEES) to the Selected list. This step creates matching view objects DepartmentsView and EmployeesView forperforming queries on the entity objects you just created.

    Click Next to continue.

    13.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    13 de 18 23/04/2013 12:57 p.m.

  • In the Query-based View Objects page, click the Query button and then move JOBS to the Selected list. This step creates aread-only view object that queries the Jobs table. Then click Next to continue.

    14.

    In the Application Module page, click Finish to create the business components in the Model project.15.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    14 de 18 23/04/2013 12:57 p.m.

  • In the Checklist, set the status of the Create Entity Objects and Associations step to Done.16.

    Click the Close Step 3 button.17.

    Click the Back to Checklist link and set the status of the Build Business Services step to Done18.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    15 de 18 23/04/2013 12:57 p.m.

  • In the Application Navigator right-click AppModule and select Run to invoke the application module tester. This is a smallSwing-based application that allows you to test the ADF Business Components you have just created.

    19.

    In the Oracle Business Component Browser window, double-click the EmpDeptFkLink1 node to show the department andemployees data. Navigate between the records using the Next button and notice the automatic master-detail synchronization.

    20.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    16 de 18 23/04/2013 12:57 p.m.

  • Click the Specify View Criteria button (binocular icon) in the master toolbar, to enter search criteria for your data. Specify1700 in the LocationID field and click the Find button to execute the query.

    21.

    The form now only shows departments in this location. Use the Next button to scroll through the departments at Location 1700.22.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    17 de 18 23/04/2013 12:57 p.m.

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

    Close the Oracle Business Component Browser window, and back in JDeveloper, click the Save All icon on the JDevelopermenu bar, or select File > Save All from the menu.

    23.

    Previous 1 2 3 Next

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

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    18 de 18 23/04/2013 12:57 p.m.

  • Part 2: Developing the User Interface

    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.

    Step 1: Create a JSF Page

    Right-click the ViewController project node in the Application Navigator, and select New...1.

    In the New Gallery, navigate to JSF/Facelets under the Web Tier node, and choose Page in the Items pane. Click OK.2.

    In the Create JSF Page dialog, rename the page to DeptEmpPage.jsf; make sure the Document Type radio button is set toFacelets, and in the Page Layout tab select the Page Template radio button and choose Oracle Three Column Layout.

    3.

    The Web part of the application is developed in a separate project called the Viewcontroller project, which you created inthe previous part of this tutorial when you created the Fusion Web application.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    1 de 35 23/04/2013 12:58 p.m.

  • Click OK.

    The page displays in the Design Editor. The template has three columns in it, but you only need two in the page, so delete thethird one.Place your cursor in the right-most section called end and right-click to choose Delete.

    With af:pageTemplate selected in the Structure pane, in the Property Inspector set the startColumnSize property to 350.

    4.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    2 de 35 23/04/2013 12:58 p.m.

  • Add some layout components to the page.In the Component Palette expand the Layout group of components and locate the Panel Accordion component in theInteractive Containers and Headers section. Drag it into the start facet of your page.

    5.

    Select af:showDetailItem (the panel accordion that you just added to the page in the previous step) in the Structure window andin the Property Inspector change its Text property to Departments.

    6.

    Right-click the new Departments accordion and choose Insert after Show Detail Item - Departments > Show Detail Item.7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    3 de 35 23/04/2013 12:58 p.m.

  • This adds another accordion to your page.

    Change the Text property to More Info.

    This is another way of adding components to a page using context menus directly inside the Design Editor (instead of draggingand dropping from the Component Palette).

    8.

    From the Layout components, click and drag a Panel Splitter component onto the center facet of your page.9.

    In the Property Inspector change the Orientation property of the new splitter to vertical.10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    4 de 35 23/04/2013 12:58 p.m.

  • From the Layout components, drag a Panel Collection component into the first facet at the top of the splitter on your page.

    A panel collection is a component that aggregates collection components like table, treeTable and tree to displaystandard/application menus, toolbars and statusbar items.

    11.

    Using the Structure window, drag a Panel Tabbed component into the second facet of the splitter on your page.12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    5 de 35 23/04/2013 12:58 p.m.

  • Double-click the tab DeptEmpPage.jsf at the top of the page to view it in its entirety. The page should look like the screenshotbelow.

    13.

    Click the Save All icon on the JDeveloper menu bar to save your work.14.

    Step 2: Bind Data Controls to the Page

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    6 de 35 23/04/2013 12:58 p.m.

  • In this step you bind the business components you created in Part 1 of this tutorial to the user interface. You do this with simple dragand drop operations; behind the scenes the ADF Model layer takes care of binding the data for you.

    In the Design Editor click the Departments accordion to expand it.1.

    In the Application Navigator expand the Data Controls accordion, and in it expand AppModuleDataControl to expose thebusiness services you defined in the first part of this tutorial.

    2.

    Drag the DepartmentsView1 data control into the Departments accordion in your JSF page. When prompted to choose thetype of component you want to create, choose Form > ADF Read-Only Form.

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    7 de 35 23/04/2013 12:58 p.m.

  • In the Edit Form Fields dialog, check the Include Navigation Controls checkbox and click OK.4.

    In the Data Controls accordion expand DepartmentsView1 to expose the fields it contains, as well as the relatedEmployeesView3 control for the employees in each department. Note that these are the "detail" employees for the "master"departments - they are linked and therefore the employees you see in this view object are the ones who belong to the particulardepartment you are looking at.

    5.

    Drag the EmployeesView3 data control onto the Panel Collection that you created in the first facet of the PanelSplitter. Create6.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    8 de 35 23/04/2013 12:58 p.m.

  • it as an ADF Read-Only Table.

    In the Edit Table Columns dialog, choose Single Row in Row Selection, and check the checkboxes for Sorting and Filtering.Click OK.

    7.

    Drag the EmployeesView3 data control again but this time onto ShowDetailItem in the panelTabbed component in the secondfacet of the panelSplitter. Create it as an ADF Form.

    8.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    9 de 35 23/04/2013 12:58 p.m.

  • In the Edit Form Fields dialog, check the Include Submit Button check box. Using your mouse and the Shift key select thebottom three fields from the list: CommissionPCT, ManagerId, DepartmentID and delete them by pressing the Delete button

    at the top right corner of the dialog box. Click OK.

    9.

    Click the Save All icon on the JDeveloper menu bar to save your work.Right-click in the page and choose Run. This will compile your project, build it, and launch the integrated WebLogic Server to runit. Then a Web browser opens up to display the page. You can follow the progress of these steps in the Log window inJDeveloper.

    10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    10 de 35 23/04/2013 12:58 p.m.

  • Once the page displays in the browser, resize the page area using the splitter to display the department data. Then use theNext button to scroll through the departments. Notice that the employee data changes accordingly in the table and the formbeneath it.

    11.

    Close the browser window.12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    11 de 35 23/04/2013 12:58 p.m.

  • Step 3: Refine the Business Services

    In these steps you refine the business services by adding validation rules, formatting and default values.

    In the Application Navigator under the Model project, locate the Employees entity object and double-click it to open it for editing.1.

    In the Employees.xml window, click the Attributes finger tab and locate the Salary attribute, and select it. Scroll down in thepage to the Validation Rules tab and click the Add icon to add a new validation rule.

    2.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    12 de 35 23/04/2013 12:58 p.m.

  • In the Add Validation Rule dialog choose Range from the Rule Type drop down list. Note the various other types of rules you candefine here. In the Operator field ensure that the value is set to Between, and type 0 for the minimum value and 99000 for themaximum value fields.

    3.

    Click the Failure Handling tab to define an error message that will display when the validation fails. In the Message Text fieldtype an error message like "Salary out of range 0 to 99,000" and click OK.

    4.

    Next you add a default value to the hire date field - so that when a new employee is created the hire date defaults to the currentdate.In the Employees.xml window, locate the HireDate attribute, and select it. In the Value section of the Property Inspector, locatethe Default Value Type property and choose Expression, then set the Default Value property to adf.currentDate. This willensure the default value for a new record is set to today's date.

    5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    13 de 35 23/04/2013 12:58 p.m.

  • You can also specify UI Hints for attributes to control how they display by default in the forms and pages that use them. In thisstep you add a default format mask for the hire date field. You can also specify labels and tooltip help here.In the UI Hints section of the Property Inspector locate the Format Type property and select Simple Date.

    6.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    14 de 35 23/04/2013 12:58 p.m.

  • Set the Format property to dd/MMM/yyyy.

    Run the page again to test the refinements you have made.7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    15 de 35 23/04/2013 12:58 p.m.

  • Test the HireDate field. Notice that as soon as you click in the field you are provided with an example of the format for the date(as you defined it).

    8.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    16 de 35 23/04/2013 12:58 p.m.

  • Try to update the field for one of the employees with an invalid date such as 11/11/123 and notice the error message when youclick the Submit button.

    9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    17 de 35 23/04/2013 12:58 p.m.

  • Use the Clock/Calendar icon next to the field to display a pop-up calendar and choose a valid date.

    Update the Salary field to a value that will break the validation you created earlier (e.g -9) and click the Submit button to see theerror message you created.

    10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    18 de 35 23/04/2013 12:58 p.m.

  • Browse to department 50 and notice that you can now scroll the data in the employees table. Click on one of the columnheaders in the table to sort the data in the table.

    11.

    Click a column heading in the table and drag it to reposition it in the table.12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    19 de 35 23/04/2013 12:58 p.m.

  • The new column order looks as follows:

    In the Filter field above the LastName column, type B% and press Enter to filter the table to show only those employees whosesurname begins with the letter B.

    13.

    Experiment with the other menus and buttons of the table to see additional functionality. Once you are finished, close thebrowser and return to JDeveloper.

    14.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    20 de 35 23/04/2013 12:58 p.m.

  • Step 4: Enhance the JSF Page

    In the next steps you enhance the user interface by modifying the table of employees to add the ability to do column selection, byreordering the fields in the Employee details tab, and by binding the business components to a graph representation. You do this withsimple drag and drop operations - behind the scenes the ADF Model layer handles the data binding for you.

    Click the DeptEmpPage.jsf tab to return to the page in the Design Editor. Select the Employees table in the Design Editor or inthe Structure pane. Set the Column Selection property of the table to Single.

    1.

    In the Structure window select the panelFormLayout that surrounds the employee details fields in the showDetailItem tab.2.

    In the Property Inspector set the Rows property to 5.3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    21 de 35 23/04/2013 12:58 p.m.

  • Next you add a graph representation of the data to the page; this is done using the ADF Data Visualization set of JSFcomponents.In the Design Editor click the More Info accordion to expand it. Then drag the EmployeesView3 data control into the More Infoaccordion and create it as a Graph.

    4.

    In the Component Gallery choose Pie from the list of graphs on the left and Pie again as the graph type. In the bottom pane,select the third Quick Start Layout.

    5.

    When you run the page in a later step you will see that the fields in the tab are now arranged in two columns.

    The graph can be displayed as static PNG image or an interactive Flash component.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    22 de 35 23/04/2013 12:58 p.m.

  • Then click the OK button.

    In the Create Pie Graph dialog choose Salary in the Pie field and drag and drop LastName into the Slices field. Click OK.6.

    Click the Save All icon on the JDeveloper menu bar to save your work and then right-click within the page and select Runfrom the context menu.

    7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    23 de 35 23/04/2013 12:58 p.m.

  • Browse to department 50. Because you set the column selection to single, note the additional behaviors for the table that areavailable once you choose a column - such as Freeze and Wrap. Select a column, then click the Freeze button. Now use thehorizontal scroll bar to view the right-most columns.

    8.

    In department 50 expand the More Info accordion and notice the graph and the popup it displays when you hover over it withyour mouse.

    9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    24 de 35 23/04/2013 12:58 p.m.

  • Scroll over to the showDetailItem1 tab, and notice how the fields have been reordered into two columns.10.

    When you are done, close the browser and return to JDeveloper.

    Step 5: Add More Complexity to the Business Services

    In this step you add a new business service to the application to display a subset of the fields from the Employees table, along with thedepartment name from the Departments table. You also add a calculated field calculating the annual salary of an employee and a list ofvalues field for department names. Oracle ADF Business Components allows you to create such complex updatable components in adeclarative way.

    In the Application Navigator right-click the demo.model package and choose New View Object.1.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    25 de 35 23/04/2013 12:58 p.m.

  • In the Name page of the Create View Object wizard, type EmpDetails as the Name and retain Entity object as the default datasource.

    Click Next.

    2.

    In the Entity Objects page of the wizard first select Employees and shuttle it to the right, and then select the Departments entityand add it also to the Selected pane.Note that only the Employees entity has the updatable checkbox checked - the departments entity is used to read data only.

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    26 de 35 23/04/2013 12:58 p.m.

  • Click Next.

    In the Attributes page of the wizard, shuttle the following Employees attributes into the Selected pane:EmployeeId, FirstName, LastName, Email, Salary, HireDate, JobId.

    And from the Departments entity, shuttle the following attributes into the Selected pane:DepartmentId, DepartmentName.

    Click Finish to complete the view object creation.

    4.

    Next you add a calculated attribute to the view object - an attribute that displays the employee's annual salary.In the Application Navigator double-click EmpDetails to open it.

    5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    27 de 35 23/04/2013 12:58 p.m.

  • Click the Attributes finger tab and from the drop down list choose New Attribute.6.

    In the New View Object Attribute dialog type AnnualSalary as the name for the new attribute and click OK.7.

    In the Details tab at the bottom of the attributes list, set the following properties for the AnnualSalary attribute:

    Field Value

    Name AnnualSalary

    Type Number

    Default Value Expression (Checked)

    8.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    28 de 35 23/04/2013 12:58 p.m.

  • Value Salary * 12

    .

    In the next steps you add a list of values to a field based on a set of values stored in another table. In this case you create a listof values for possible job titles based on the Jobs table.In the EmpDetails.xml editor click the Attributes finger tab and select the JobId attribute. Click the List Of Values tab at thebottom of the attributes list.

    9.

    In the List of Values tab click the Add button to create a list of values.10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    29 de 35 23/04/2013 12:58 p.m.

  • In the Create List of Values dialog click the green plus to the right of the List Data Source field. In the View Accessors dialog,shuttle JobsView into the View Accessors pane.

    Click OK.

    11.

    Back in the Create List of Values dialog, choose JobId as the List Attribute.12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    30 de 35 23/04/2013 12:58 p.m.

  • Still in the Create List of Values dialog click the UI Hints tab and choose Combo Box with List of Values as the Default ListType and then shuttle the Job Title attribute into the Selected pane.

    Click OK. Save your work.

    13.

    Now you add the new object that you've created to the data model.In the Application Navigator double-click AppModule to open it for editing and choose the Data Model finger tab.

    14.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    31 de 35 23/04/2013 12:58 p.m.

  • Click the EmpDetails view object and shuttle it into the Data Model pane.Save your work.

    15.

    Use the Business Component Browser to test the new functionality you have just incorporated through the EmpDetails viewobject. In the Application Navigator right-click AppModel and select Run to invoke the tester.

    16.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    32 de 35 23/04/2013 12:58 p.m.

  • Double-click the EmpDetails1 view object.17.

    Notice that the new calculated AnnualSalary field is displayed, along with DepartmentId and DepartmentName. None of thethem are updatable here.

    18.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    33 de 35 23/04/2013 12:58 p.m.

  • Use the drop down list for the JobId field to choose a new job.19.

    The field is populated with the new job.20.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    34 de 35 23/04/2013 12:58 p.m.

  • Close the Business Component Browser window without committing the changes.21.

    Previous 1 2 3 Next

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

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    35 de 35 23/04/2013 12:58 p.m.

  • Part 3: Enhancing the User Interface

    Web applications usually have more than one page in them. In this part of the tutorial you add another page - a Search page - to yourapplication and use the ADF Task Flow Diagrammer to define the navigation rules between the two pages. You then use features of theADF Faces Framework to add extra functionality to the pages. Finally you create a reusable page fragment and add it to theDeptEmpPage page.

    Step 1: Create a Page Flow

    In the Application Navigator locate the adfc-config file under the Page Flows node in the ViewController project. Double-click itto open it in the editor. This is where you are going to define the application's navigation.

    1.

    Drag the DeptEmpPage.jsf file from the Application Navigator into the empty adfc-config diagram.2.

    From the Component Palette drag and drop a View component into the adf-config diagram, and rename it query. Thisrepresents the new JSF page that you are about to create.

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    1 de 46 23/04/2013 12:59 p.m.

  • From the Component Palette select Control Flow Case and then click on the DeptEmpPage and drag a line to the query page.

    Name this line goQuery.

    4.

    From the Component Palette choose another Control Flow Case and then create an opposite flow from the query page to theDeptEmpPage. Name this flow back.

    5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    2 de 46 23/04/2013 12:59 p.m.

  • Double-click the query view in the diagram to create the new page. In the Create JSF Page dialog accept the default Faceletsradio button, and with the Quick Start Layout radio button selected, click Browse.

    6.

    In the Component Gallery, retain the default One Column category, type and layout, but check the Apply Themes checkbox inthe Options pane.

    7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    3 de 46 23/04/2013 12:59 p.m.

  • Click OK and OK again to create the page.

    To add the employees search functionality to the page, open the Data Controls accordion, and locate EmpDetails1. (If you donot see it click the Refresh button).

    8.

    Expand the EmpDetails1 data control and expand the Named Criteria node below it. Select All Queriable Attributes and dragit into the new query.jsf page. Create it as a Query > ADF Query Panel.

    9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    4 de 46 23/04/2013 12:59 p.m.

  • In the Data Controls accordion select the EmpDetails1 data control and drag it into the center area of the page below the querycomponent. Create it as a Form > ADF Form.

    In the Edit Forms Details, check both the Include Navigation Controls and the Include Submit Button checkboxes. Click OK.

    10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    5 de 46 23/04/2013 12:59 p.m.

  • With the panelFormLayout still selected, use the Property Inspector to set the Rows property to 5.11.

    In the Structure window locate the Submit button, right-click it and choose Insert after af:command:Button - Submit >Button.

    12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    6 de 46 23/04/2013 12:59 p.m.

  • In the Property Inspector change the Text of the new button to Back and for the Action property select back from the drop downlist. This causes the button to perform the navigation you defined in the page flow diagram.

    13.

    Next you add transaction operations to the page to allow you to commit and rollback changes. In the Data Controls Paletteexpand the application module level Operations node to locate the commit and rollback operations. Drag the Commit operationinto the Structure window before the First Button. When prompted for a drop target choose ADF Button.

    14.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    7 de 46 23/04/2013 12:59 p.m.

  • Repeat the same steps for the Rollback operation.15.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    8 de 46 23/04/2013 12:59 p.m.

  • In the Property Inspector, for the Rollback and for the Commit buttons, reset the Disabled property to default to make bothbuttons always selectable.

    16.

    Double-click the Query.jsf tab to maximise the page in the Design Editor. Your page should look as follows:17.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    9 de 46 23/04/2013 12:59 p.m.

  • Click the DeptEmpPage.jsf tab to switch back to the page. A quick way to navigate to this or any other file is by using the globalfind box at the top right of JDeveloper and typing the file name there.

    Then just click the file name to open it in the editor.

    18.

    In the page design, expand the Departments accordion. From the Component Palette, choose a Button component and drag itinto the Departments accordion between the First and Previous buttons. Alternatively you can right-click the First button andchoose insert after > button to add the new button.

    19.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    10 de 46 23/04/2013 12:59 p.m.

  • Using the Property Inspector change the Text of the button to Query and for the Action property type goQuery or select it fromthe drop down list if available. This causes the button to perform the navigation you defined in the page flow diagram.

    20.

    Click the Save All icon on the JDeveloper menu bar to save your work, and then right-click the DeptEmpPage.jsf page andchoose Run.

    21.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    11 de 46 23/04/2013 12:59 p.m.

  • When the page displays in your browser click the Query button to navigate to the new page. In the Search page click Advancedto display detailed search criteria.

    22.

    In the FirstName field accept the default Starts with, and type the letter G.Press Search.The form below displays the record for Guy Himuro.

    23.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    12 de 46 23/04/2013 12:59 p.m.

  • Experiment with the form, saving your search criteria, creating more complex queries and updating data for employees. Notehow this form displays a view of the data that matches the definition in the view object you created - including information forDepartment name as well as a list of values for the Job id and the employee's annual salary.You can also make changes to the data and commit and rollback your transactions as needed.

    When you are finished close the browser window.

    24.

    Step 2: Use Partial Page Refresh

    In the next steps you become acquainted with some of the features of the ADF Faces Framework. You enhance your pages withadditional Ajax functionality leveraging the declarative development features offered by ADF Faces components.

    Open the query.jsf file in the Design Editor, if it is not already open. Select the Salary field. In the Property Inspector set thevalue of the Id property to sal.

    1.

    In the next few substeps you use the partial page refresh capability offered by ADF Faces.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    13 de 46 23/04/2013 12:59 p.m.

  • Still in the Property Inspector expand the Behavior node and set the AutoSubmit property to True.2.

    In the Structure window locate the AnnualSalary field. (Another option to get to this field is to double-click the query.jsf tab tomaximize the window and then locate the field in the Design Editor).Locate the PartialTriggers property under the Behavior section and click the arrow to its right to choose Edit.

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    14 de 46 23/04/2013 12:59 p.m.

  • In the Edit Property dialog locate the Salary field and shuttle it to the right using the blue arrow. Click OK.4.

    Click the Save All icon on the JDeveloper menu bar to save your work, and run DeptEmpPage.jsf.5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    15 de 46 23/04/2013 12:59 p.m.

  • When the page displays, click the Query button in the Departments panel.6.

    In the Search page search for employees whose first name begins with A%.7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    16 de 46 23/04/2013 12:59 p.m.

  • Note the salary and annual salary values.

    Update the Salary field and then tab out of it. Notice the immediate change to the AnnualSalary field once you leave the Salaryfield. However this is the only field that is refreshed (not the whole page).

    8.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    17 de 46 23/04/2013 12:59 p.m.

  • Close the browser.9.

    Step 3: Use the ADF AutoSuggest Behavior

    In the query page, select the JobId field.1.

    In the Component Palette expand the Operations node, and locate Auto Suggest Behavior in the Behavior section. Drag anddrop the Auto Suggest Behavior operation onto the JobId field.

    2.

    The af:autoSuggestBehavior component displays a drop down list of suggested items when the user types into an inputcomponent.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    18 de 46 23/04/2013 12:59 p.m.

  • In the Insert Auto Suggest Behavior dialog box type #{bindings.JobId.suggestedItems}. Click OK.3.

    Save your work and then run the query page.4.

    Type 121 in the EmployeeId field, and click the Search button. In the record for Adam Fripp update the JobId field by typing 's' init. A number of jobs beginning with 's' are suggested.

    5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    19 de 46 23/04/2013 12:59 p.m.

  • Add 'a' after the 's' and see the list of suggestions modified accordingly.6.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    20 de 46 23/04/2013 12:59 p.m.

  • Choose Sales Representative from the three remaining options, to populate the field.7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    21 de 46 23/04/2013 12:59 p.m.

  • Close the browser without saving the change.8.

    Step 4: Use Drop Down Menus and Operation Components

    In this step you add a drop down menu to a page and use a couple of ADF Faces operation components to add Javascript-basedoperations to the page - to export table data into an Excel spreadsheet and to create a printable page.

    In the DeptEmpPage.jsf file click inside the menus facet in the panel collection surrounding the Employees table. Right-click andfrom the context menu choose Insert Inside Facet menus > Menu.

    1.

    In the Property Inspector set the Text property to My Options.2.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    22 de 46 23/04/2013 12:59 p.m.

  • In the Property Inspector expand the Behavior node and set the Detachable property to true.3.

    In the Structure window right-click the menu component and choose Insert inside af:menu - My Options > Menu Item.4.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    23 de 46 23/04/2013 12:59 p.m.

  • In the Property Inspector set the Text property of the new menu item to Export to Excel.5.

    With the new Export to Excel menu item still selected in the Structure window, expand the Listeners section of the Operationsnode of the the ADF Faces components in the Component Palette.Locate the Export Collection Action Listener component and drag it onto the Export to Excel menu option in the Structurewindow.

    6.

    In the Insert Export Collection Action Listener dialog click the down arrow next to ExportedId field and choose Edit.7.

    In the Edit Property dialog navigate through the page structure to locate the table - t1 component and select it. Click OK.8.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    24 de 46 23/04/2013 12:59 p.m.

  • From the Type drop down list select excelHTML and click OK.9.

    Add another menu option to the menu. In the Structure window right-click the Export to Excel menu component and from thecontext menu choose Insert After af:commandMenuItem - Export to Excel > Menu Item.

    10.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    25 de 46 23/04/2013 12:59 p.m.

  • Set the Text property of this new menu option to Printable Page.11.

    In the Behavior section under the Operations node of the Component Palette select the Show Printable Page Behavioroperation to add it to the new menu item. Drag and drop it onto the new menu option you created.

    12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    26 de 46 23/04/2013 12:59 p.m.

  • Click the Save All icon on the JDeveloper menu bar to save your work, and then choose Run.13.

    When the page displays click the new menu and detach it.14.

    Then invoke each one of the menu options you created, for example Export to Excel.

    You may need to accept the download of the file in the browser window to be able to access the Excel file.

    15.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    27 de 46 23/04/2013 12:59 p.m.

  • Try the Printable Page menu option.

    The page is ready for printing.

    Close the browser window.

    16.

    Step 5: Add CRUD Operation Components to your Page

    Click the query.jsf tab to return to the Query page, opening the Structure pane. In the Data Controls accordion expand theEmpDetails1 node and then the Operations node below it. Select the CreateInsert operation.

    1.

    The next few tasks examine some of the data operations that JDeveloper makes available to view objects. You see how to add aDelete operation and a CreateInsert operation. When the user clicks the CreateInsert button to insert the new row you want thetable to refresh to display the new empty row. To do this you again use the Partial Page Refresh feature that was covered in Step 2of this part of the tutorial.The view object uses a bind variable to pass the employee's email into the query.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    28 de 46 23/04/2013 12:59 p.m.

  • Drag the CreateInsert operation in the Structure pane onto the panelGroupLayout in the footer facet of the employees form.Create it as an ADF Button.

    2.

    In the Property Inspector set the Id property for the button to CreateInsert.3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    29 de 46 23/04/2013 12:59 p.m.

  • Still in the Property Inspector expand the Behavior node and in the PartialTriggers property choose Edit from the dropdownlist.

    4.

    In the Edit window scroll through the page's components until you find the CreateInsert button. Shuttle it into the Selected pane.5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    30 de 46 23/04/2013 12:59 p.m.

  • Click OK. This action defines the CreateInsert component as the trigger that will cause the table to refresh.

    In the same way add a Delete operation by dropping the Delete operation from EmpDetails1 onto the panelGroupLayout in thepage footer. As before, create it as an ADF button.

    6.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    31 de 46 23/04/2013 12:59 p.m.

  • The two buttons display at the bottom of the query page.7.

    Save your work and then run the Query page.8.

    When the page displays type F% in the LastName field and click the Search button. The first F% employee record displays.9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    32 de 46 23/04/2013 12:59 p.m.

  • Click the CreateInsert button. The page refreshes and the fields are cleared down (except for the HireDate field, which you setto default to the current date) so that a new record can be inserted.

    10.

    Step 6: Create a Query-only Business Service Based on Parameters

    In the Application Navigator locate the demo.model package and right-click it to choose New View Object....1.

    In the Create View Object wizard set the Name property to EmpByEmail and choose the SQL Query radio button as the datasource. Click Next.

    2.

    In this step you create a view object that allows end users to search for an employee's name based on their email address.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    33 de 46 23/04/2013 12:59 p.m.

  • In Step 2 of the Create View Object wizard type the following query:

    The ':' before p_email means that it is a variable that will be passed to the query.

    Click the Test and Explain button to verify your query.

    Click Close and then click Next.

    3.

    In Step 3 of the Create View Object wizard, click the New button to define a new bind variable. Set the Name property top_email.

    4.

    select first_name,last_name from employees where email=:p_email

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    34 de 46 23/04/2013 12:59 p.m.

  • Click the Control Hints tab and set the Label Text to Email.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    35 de 46 23/04/2013 12:59 p.m.

  • Click Next a few more times to accept all the defaults, until you get to step 8 of the wizard.Here check the Add to Application Module check box to include your new view in the data model.Click the Finish button.

    5.

    Save your work and then run the Business Component Browser to test the new view. Double-click the new EmpByEmail1view and when prompted to insert a value for the variable enter SKING and press OK to get the results for this email address.

    6.

    Running the Business Component Tester.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    36 de 46 23/04/2013 12:59 p.m.

  • To try another value click the Edit Bind Variables button.

    Close the Business Component Browser.

    7.

    Step 7: Create a Reusable Page Fragment

    In this step you create a reusable page fragment.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    37 de 46 23/04/2013 12:59 p.m.

  • First create a new task flow specifically for this page.In the Application Navigator right-click the ViewController project and choose New...

    1.

    In the Web Tier > JSF/Facelets category choose ADF Task Flow.

    Click OK.

    2.

    In the Create Task Flow dialog set the File Name property to search-email-flow.xml.Verify that the Create As Bounded Task Flow and Create with Page Fragments checkboxes are both checked.

    3.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    38 de 46 23/04/2013 12:59 p.m.

  • Click OK.

    In the Design Editor drag a View component from the Component Palette onto the empty diagram and name it searchEmail.You only use a single page in this flow, but you can have bounded task flows with multiple pages and still include them in otherJSF pages.

    4.

    Double-click the new searchEmail view component to create the page fragment for it.Accept all the defaults in the dialog that displays and make sure the file name is searchEmail.jsff. This creates the page as apage fragment that can be included in other JSF pages. Click OK.

    5.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    39 de 46 23/04/2013 12:59 p.m.

  • An empty page displays in the Design Editor. Expand the Data Controls accordion and, if necessary, click the Refresh button toensure that the new EmpByEmail data control appears in the list.

    6.

    Expand the new EmpByEmail1 view and the Operations node beneath it. Select the ExecuteWithParams operation. You aregoing to use this operation to execute the query for this view passing it the necessary parameter.

    7.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    40 de 46 23/04/2013 12:59 p.m.

  • Drag the ExecuteWithParams operation to your new page, and create it as an ADF Parameter Form....8.

    In the Edit Form Fields dialog change the display label for the p_email value from default to Email. Click OK.9.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    41 de 46 23/04/2013 12:59 p.m.

  • In the Design Editor for the page, click the ExecuteWithParams button and use the Property Inspector to change the Textproperty to Find Details.

    10.

    From the Data Controls accordion, drag the EmpByEmail1 view onto the page beneath the button. Create it as a Form > ADFRead-only Form....

    11.

    Accept the defaults presented in the Edit Form Fields dialog and click OK. Save your work.12.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    42 de 46 23/04/2013 12:59 p.m.

  • The page should look like this:

    The new bounded task flow now contains a page fragment; next you include the complete bounded task flow inside another JSFpage.In the Application Navigator locate the DeptEmpPage.jsf file and open it in the Design Editor, if it is not already open. From theComponent Palette Layout section drag and drop a Separator component into the left accordion in the DeptEmpPage.jsf pagebeneath the Departments form.

    13.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    43 de 46 23/04/2013 12:59 p.m.

  • Add the new flow you created as a region to the existing page.From the Application Navigator drag and drop the search-email-flow.xml file into the left accordion in the DeptEmpPage.jsfpage beneath the new separator. Create it as a Region.

    14.

    Your page should now look like the screenshot below.15.

    Save your work and then run the updated DeptEmpPage.jsf page.When the page displays in your browser test the new functionality by entering an email value in the Email field and pressing theFind Details button.

    16.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    44 de 46 23/04/2013 12:59 p.m.

  • The employee name information is returned.17.

    Summary

    In this tutorial you built a small Web application that interacts with a database. You learned how to:

    Build the business services that supply the data to the application

    Create a data-bound JSF page

    Enhance the page by adding more complex operations

    Add a second JSF page to the application and create a page flow diagram to define the navigation between the pages

    Create a reusable page fragment containing a business service based on parameters

    To learn more about building rich Web applications, refer to:

    "Developing Applications Using Web Page Tools" in User's Guide for Oracle JDeveloper

    Web User Interface Developer's Guide for Oracle ADF

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    45 de 46 23/04/2013 12:59 p.m.

  • Previous 1 2 3 Next

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

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Appli... http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_55/jdtut_11r2...

    46 de 46 23/04/2013 12:59 p.m.

    Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Applications With Oracle ADFOracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Applications With Oracle ADF2Oracle JDeveloper 11g Release 2 Tutorials - Developing Rich Web Applications With Oracle ADF3