Oracle ADF 11g Developer LessonName – Rakesh GujjarlapudiEmail Address – rakesh_gujj@yahoo.com
OVERVIEW       Installing Oracle Express 10g Database       Installing Oracle WebLogic Server 11g & JDeveloper 11g     ...
LESSON 1 – CREATING AN ADF APPLICATIONSummary:This exercise will walk you through the steps of creating a rich internet ap...
In the Create Application dialog box,       Specify the Application Name to: HRSystem.       Notice that the directory c...
Specify the following properties for the new connection you are creating:Connection Name: HRConnUsername: HRPassword: welc...
Click the Build Business Services step to expand it, then click the Go to Substeps buttonIn the subtask list, click the Cr...
In the Initialize Business Components Project dialog, verify that the HRConn connection is alreadyselectedClick OK in the ...
NOTE: This step creates updateable Entity Objects based on the tables you chose.Click Next to continueIn the Updateable Vi...
In the Subtask list, click on the Close Step 3 button        Set the status of the Build Business Services step to DoneSte...
project called the viewcontroller project. This separation between the Model layer and the user interface makesthe busines...
5. Wait for the DeptEmpPage.jspx page to initialize and render in the visual design view. The template has   three columns...
9. From the Layout components, click-and-drag a Panel Splitter component onto the Center area of your   page10. In the Pro...
12. From the Layout components, click-and-drag a Panel Tab component into the second area at the    bottom of the splitter...
Step C: Binding Data Controls to your JSF pageIn the next few steps you are going to bind the business components you crea...
3. Drag the DepartmentsView1 data control into the Departments accordion in your JSF page. When   prompted to choose a com...
5. In the Data Controls accordion expand the DepartmentsView1 control to expose the fields it contains as   well as the re...
8. Drag the DepartmentsView1  EmployeesView3 data control again but this time into the Tab on the   bottom right side of ...
10. Your JSP should look like the image below11. Click the Save All   icon on the JDeveloper menu bar to save your workAt ...
LESSON 2 - DEPLOYING & RUNNING ADF APPLICATION ONWEBLOGIC SERVERSummary:This exercise will walk you through the steps of e...
4. On the Name and Domain screen of the New Application Server wizard, enter the following:       a. Name: testdomain_wls1...
b. Check the Let JDeveloper manage the lifecycle for this Server Instance checkbox   NOTE: The Domain Directory and Server...
d. Click on the     icon next to the Server Instance text box to browse to the   /home/oracle/Oracle/JDev11113/user_projec...
5. On the Authentication screen of the wizard, enter the following values and click Next       a. Username: weblogic      ...
8. On the Finish screen of the New Application Server Wizard, click Finish
9. Once you click Finish in the previous step, the new application server configuration   (testdomain_wls11gserver) should...
Step B: Modifying ADF Application & Project Properties to use testdomain_wls11gserverIn the next few steps we are going to...
5. In the AppModule panel, select Configurations6. In the Configurations panel, select the AppModuleLocal configuration an...
7. In the Edit Business Components Configuration dialog, change the Connection Type to JDBC      DataSource, and click OK ...
2. Since this is the first time the JSP page is being run, JDeveloper will do several things:       a. Compile the HRSyste...
4. Try to update the Hire Date field for one of the employees with an invalid date such as 11/11/123 and   notice the erro...
6. Click a column heading in the table and drag it to reposition the column in the table7. In the Filter field above the L...
LESSON 3 – ADF DATA VISUALIZATION COMPONENTSSummary:In this lab you are going to enhance your JSF page by changing the tab...
The graph component is one of the ADF Faces Data Visualization components. The Graph can bedisplayed as static PNG image o...
Then click the OK button.Select the dvt:pieGraph from the structure paneIn the Property Inspector, note that you can chang...
Browse to department 30. Because you set the column selection to single, note the additional behaviorsfor your table that ...
When done, close the browser and return to JDeveloper.You are now completed with Lab 3: ADF Data Visualization Components
LESSON 4 – CREATING MORE COMPLEX BUSINESSCOMPONENTSSummary:In this section well add a new, more complex, Business Service ...
Note that only the Employees entity has the updateable checkbox checked - the Departments entity isused to read data only....
In the EmpDetails.xml editor switch to the Attributes section and click the Add button to add a newattribute.In the New Vi...
In the View Accessors dialog shuttle the JobViews to the right.Click the OK button.In the EmpDetails.xml editor switch to ...
In the List of Values dialog select JobsView1 for the List Data Source field, and JobId as the List Attribute.Still in the...
Click the EmpDetails view object and shuttle it to the right.In the Application Navigator Right-click AppModel and select ...
The selected job gets populated.Close the Business Components Tester window without committing the changes and back in JDe...
LESSON 5 – CREATING MULTIPLE PAGE WEBSITES –PAGE FLOWSSummary:Web applications usually have more than one page in them. In...
From the Component Palette choose a Control Flow Case and then click on the DeptEmpPage and drag aline to the query page.N...
Click OK.In the Structure pane, select the end and start facets from the template and right click to delete them.In the Da...
In the Data Controls accordion select the EmpDetails1 data control and drag it into the center area ofthe page below the q...
Click OK.In the structure pane locate the Submit button, right click it and choose Insert after af:command:Button- Submit ...
Next well add transaction operations to the page to allow you to commit and rollback changes. In theData Controls Palette ...
In the Property Inspector, for the Rollback and for the Commit buttons, expand the Behavior section andset the Disabled pr...
Then just click the file name to open it in the editor.In the page design, expand the Departments accordion. From the Comp...
Click the Save All icon on the JDeveloper menu bar to save your work, and then right click theDeptEmpPage.jspx page and ch...
Choose the Accountant title and click OK.Now click the Search button in the Query page to return the results in the form b...
Close your browser window.
LESSON 6 – CREATING JEE5 STATELESS SESSION EJBSSummary:In this lab, a new project will be added to the HRSystem applicatio...
4. Take the defaults on the Configure Java Settings page then select “Next”5. In the “Configure EJB settings” page, keep t...
6. Change the name of the EJB to “CreditScore” and keep the other default settings then select “Next”:   In the Class Defi...
In the next screen, you can see that the wizard gives the option of either creating a Remote Interface, aLocal Interface o...
The CreditScoreApp Overview page will be displayed so you can see an overall view of the EJB7. Open up the editor for the ...
9. Now we need to expose this new method from the EJB’s remote and local interfaces. Open up the files   “CreditScore.java...
First, we need to create a new deployment profile. A deployment profile tells JDeveloper how topackage up the application ...
Select “OK” again to dismiss the Project Properties dialog.   Select the Save All – now we’re ready to deploy11. Now we wi...
Select “testdomain_wls11gserver” from the list of available WebLogic server instances. Make sure thatthe “Overwrite module...
Check that the deployment finished successfully in the “Deployment” tab in JDeveloper12. You can also choose to review the...
This will bring up a small dialog asking which project you would like to put the test client in, or if you’dlike to create...
Right-click on CreditScoreLocalClient.java and select RunYou should now see the output from the test client program which ...
LESSON 7 – CREATING JAX-WS WEB SERVICESSummary:In this lesson, the Stateless EJB just created in the previous lab will be ...
3. On the Message Format page, select “SOAP 1.2 Binding” and keep the default “Document/Wrapped”   SOA Message Format. Do ...
5. Open up the “CreditScoreBean.java” file and note the new annotations that have been added giving this   EJB a web servi...
8. Now, let’s test the new web service interface created for this EJB. Back in JDeveloper, right-click on the   CreditScor...
Then select the “Testing” tab:Expand the “CreditScoreBeanService” node to expose the test point for the web service:Select...
You can test out different values of the input argument by selecting the “Show Operations” button                         ...
Name your new project “TotalSalaryService” and then select “Web Services” in the Project Technologies    list to shuttle o...
4. The Create Java Web Service from WSDL wizard will now come up. Select “Next” on the Welcome page.   On the “Select Depl...
5. At this point JDeveloper generates the java classes based on the WSDL definition. It will be our   responsibility to de...
case 9:  totalSalary = "400000"; // good credit score}return totalSalary;This business logic is similar to the Stateless S...
Once the test client comes up in the web browser, input a value of “800” into the DepartmentIdInfo,then select the “TotalS...
LESSON 8 – ADDING THE NEW SERVICES INTO THEADF APPLICATIONSummary:In this lab, we will take the Stateless Session EJB and ...
Shuttle the “getCreditScore” operation from the “Available” side to the “Selected” side then select“Next”Select the getCre...
Don’t select any authentication for the endpointReview the settings for the data control, then select Finish
The Data Control will be created and will show up in the Data Controls view. We are now ready to add it   to the HRSystem’...
Next, drag and drop the Data Controls -> CreditScoreDataControl -> getCreditScore(String) -> Integer    return value just ...
6. Expand the “Employee Credit Score” accordion and test different Employee IDs to verify it’s hitting the      backend EJ...
Name this Data Control “TotalSalaryDataControl”. Copy the WSDL URL from the WebLogic console in asimilar manner as was don...
Select the TotalSalary operation and ensure that the response format is XML then select “Next”For this lab, don’t select a...
Review the configuration and select “Finish” to create the new Data Control for the TotalSalaryService2. Now, we will add ...
Change the Display Label to “Department ID”, then select “OK”4. Finally, drag and drop the Data Controls -> TotalSalaryDat...
5. Change the label of the output textbox to “Total Salary” from it’s default value of   #{bindings.Return.hints.label}6. ...
Note: it is possible that in the WebLogic console (in JDeveloper “Running: testdomain_wls11gserver –Log” tab) there will b...
LESSON 9 – DATA VALIDATION (OPTIONAL)Summary:This exercise will enhance the application that we have created. In this lab ...
3. In the Employees.xml window, click the Attributes node and locate the Salary attribute, and click it.   Scroll down in ...
5. Click the Failure Handling tab to define an error message that will appear when the validation fails. In   the Message ...
7. You can also specify UI Hints for attribute to control how they will display by default in the forms and   pages that w...
9. Enter an out of range value as salary to check validation and the error message.    Click the Insert Record button and ...
Click the Save All icon on the JDeveloper menu bar, or select File | Save All from the menu.10. Redeploy the application a...
Upcoming SlideShare
Loading in...5
×

Oracle ADF 11g Tutorial

22,199

Published on

The tutorial describes the following topics in detail



CREATING AN ADF APPLICATION

DEPLOYING & RUNNING ADF APPLICATION ON WEBLOGIC SERVER

ADF DATA VISUALIZATION COMPONENTS

CREATING MORE COMPLEX BUSINESS COMPONENTS

CREATING MULTIPLE PAGE WEBSITES – PAGE FLOWS

CREATING JEE5 STATELESS SESSION EJBS

CREATING JAX-WS WEB SERVICES

ADDING THE NEW SERVICES INTO THE ADF APPLICATION

DATA VALIDATION (OPTIONAL)

6 Comments
50 Likes
Statistics
Notes
No Downloads
Views
Total Views
22,199
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
6
Likes
50
Embeds 0
No embeds

No notes for slide

Transcript of "Oracle ADF 11g Tutorial"

  1. 1. Oracle ADF 11g Developer LessonName – Rakesh GujjarlapudiEmail Address – rakesh_gujj@yahoo.com
  2. 2. OVERVIEW  Installing Oracle Express 10g Database  Installing Oracle WebLogic Server 11g & JDeveloper 11g  Creating a WebLogic Server 11g DomainWebLogic Server 11g Info:MIDDLEWARE_HOME=/home/oracle/Oracle/JDev11113Configuration Wizard = ${MIDDLEWARE_HOME}/wlserver_10.3/common/bin/config.shDomain Home: /home/oracle/Oracle/JDev11113/user_projects/domains/testdomainAdmin Server Console: http://localhost:7001/consoleUser: “weblogic”/”welcome1” is user/password for the administration console on this domain.JDeveloper 11.1.1.3.0 Info:JDeveloper Executable = ${MIDDLEWARE_HOME}/jdeveloper/jdev/bin/jdevLab Project Location = /home/oracle/jdeveloper/mywork/HRSystemOracle XE Info:Database Version: 10.2.0 (10g)Starting Oracle XE: /etc/init.d/oracle-xe startStopping Oracle XE: /etc/init.d/oracle-xe stopUser: sys / welcome1User: HR / welcome1JDK Info:JDK1.6.0_22 – installed at: /usr/local/bin/jdk1.6.0_22
  3. 3. LESSON 1 – CREATING AN ADF APPLICATIONSummary:This exercise will walk you through the steps of creating a rich internet application using ApplicationDevelopment Framework (ADF) using JDeveloper. The purpose of this lab is to get you some familiarity withJDeveloper and ADF. In this lab, we will create an ADF application that connects to a backend database andretrieves information abbot departments and employees in that department. Additionally, the ADF applicationwill allow you to make changes to an employee’s data and submit those changes back to the database.Relevant Links:Documentation for ADF can be found here:http://www.oracle.com/technetwork/developer-tools/adf/documentation/index.htmlActivity Steps:Step A: Creating a New ADF Application and Business ComponentsWhen you work in JDeveloper, you organize your work in projects within an application. JDeveloper providesseveral templates that you can use to create an Application and projects. The templates are pre-configured witha basic set of technologies that are needed for developing various types of applications, and you create yourworking environment by selecting the template that fits your needs. You can then configure it to add any othertechnologies you plan to use. In the first section you are going to create a new Application using the Fusiontechnology and build reusable business components that will access the database. Youll be using the OracleADF Business Components technology to map Java objects to existing tables in your database. 1. Launch JDeveloper by double-clicking the desktop icon In JDeveloper, click on View ->Application Navigator In the JDeveloper Application Navigator, click New Application.
  4. 4. In the Create Application dialog box,  Specify the Application Name to: HRSystem.  Notice that the directory changes to match the new name.  Specify the Application Package Prefix to be: demo.  In the Application Templates choose the Fusion Web Application (ADF)  Click FinishIn the CheckList pane, click the Connect to a Database stepThe step expands showing useful information such as prerequisites required for performing this task.Click the Create a Database Connection button.
  5. 5. Specify the following properties for the new connection you are creating:Connection Name: HRConnUsername: HRPassword: welcome1SID: XEClick the Test Connection button on the Create Database Connection dialog to verify that a successfulconnectionOnce done, click the OK button to exit out of the Create Database Connection dialogClick the down arrow to collapse the Connect to a Database stepIn the Checklist pane, set the status of the Connect to a Database step to Done
  6. 6. Click the Build Business Services step to expand it, then click the Go to Substeps buttonIn the subtask list, click the Create Entity Objects and Associations subtaskClick the Create Entity Objects and Associations buttonIn the Select Project for Action dialog, select the Model project
  7. 7. In the Initialize Business Components Project dialog, verify that the HRConn connection is alreadyselectedClick OK in the Initialize Business Components Project dialogIn the Entity Objects page, click the Query button to examine the data dictionary and see availabletablesSelect the DEPARTMENTS and EMPLOYEES tables in the Available list, and click the right arrow tomove your selections to the selected list.
  8. 8. NOTE: This step creates updateable Entity Objects based on the tables you chose.Click Next to continueIn the Updateable View Objects dialog, move Departments (DEPARTMENTS) and Employees(EMPLOYEES) to the selected listNOTE: This step creates matching view objects DepartmentsView and EmployeesView to performqueries on the entity object you created before.Click Next to continueIn the Read Only View Objects dialog, click the Query button and then move JOBS to the Selected listNOTE: This step creates a read only view object that queries the Jobs tableClick Next to continueIn the Application Module dialog, click Finish to create the business components in the Model project
  9. 9. In the Subtask list, click on the Close Step 3 button Set the status of the Build Business Services step to DoneStep B: Creating JSF Web pagesHaving completed the creation of the business components (Model and View objects), we can now build theuser interface using JavaServer Faces (JSF), which is a standard Java EE technology that simplifies Webdevelopment.In this section you create a JSF page to access the business components that you created in the previous section.You learn how to create a form that can be used to displays and modify data. Youll also use a master-detailrelationship to display the information about employees in each department. To build the page youll be usingthe Oracle ADF Faces Rich Client Components - these components allow you to build Ajax-based rich Web UIwithout writing low level HTML and Javascript code. The Web part of the application is developed in a separate
  10. 10. project called the viewcontroller project. This separation between the Model layer and the user interface makesthe business services more reusable. 2. Well start by creating a new Web page. In the Application Navigator panel, Right-click the ViewController project node, and select New. 3. In the New Gallery window, navigate to the Web Tier  JSF node, and choose the JSF Page option, and click OK 4. In the Create JSF Page dialog box, a. Rename the page to DeptEmpPage.jspx, b. In the Page Template drop down box select Oracle Three Column Layout c. Make sure the Create as XML Document is checked d. Click OK
  11. 11. 5. Wait for the DeptEmpPage.jspx page to initialize and render in the visual design view. The template has three columns in it, since we only need two in our page, well delete the third one. Place your cursor in the right-most section called end and right click to choose Delete6. In the Structure pane, with the af:pageTemplate selected, in the Property Inspector set the startColumnSize value to 350 to enlarge it7. Now we are going to add some layout components to our page. In the component palette window expand the Layout accordion and click-and-drag the Panel Accordion component into the Start area of your page8. Click the ShowDetails1 accordion that was created on the page, and in the Property Inspector change its Text property to Departments
  12. 12. 9. From the Layout components, click-and-drag a Panel Splitter component onto the Center area of your page10. In the Property Inspector change the Orientation property of the new splitter to be Vertical11. From the Layout components, click-and-drag a Panel Collection component into the first area at the top of the splitter on the JSP page
  13. 13. 12. From the Layout components, click-and-drag a Panel Tab component into the second area at the bottom of the splitter on the JSP page13. Click on the ShowDetailItem1 tab that is created in the bottom area of your splitter, and in the Property Inspector change its Text property to Employee14. Your page should look like the image below15. Click the Save All icon on the JDeveloper menu bar to save your work
  14. 14. Step C: Binding Data Controls to your JSF pageIn the next few steps you are going to bind the business components you created to your user interface. Youlldo this with simple drag and drop operations - behind the scene the ADF Model layer takes care of this bindingfor you. 1. In the Page design pane, click the Departments accordion to expand it 2. In the Application Navigator expand the Data Controls accordion, and in it expand the AppModuleDataControl to expose the business services you defined in the first part of this lab
  15. 15. 3. Drag the DepartmentsView1 data control into the Departments accordion in your JSF page. When prompted to choose a component to Create choose Forms->ADF Read-Only Form4. In the Edit Form fields dialog, a. Change the Display Labels from <default> to appropriate labels as follows: i. Department ID ii. Department Name iii. Manager ID iv. Location ID b. Check the Include Navigation Controls check box c. Click OK
  16. 16. 5. In the Data Controls accordion expand the DepartmentsView1 control to expose the fields it contains as well as the related EmployeesView3 control for the employees in each department NOTE: The DepartmentsView1  EmployeesView3 have a master-detail relationship. EmployeesView3 are the detail employees for the DepartmentsView1 master departments - they are linked and therefore the employees youll see in this view object will be the ones working in a specific department you are looking at.6. Drag the DepartmentsView1  EmployeesView3 data control into the Panel Collection on the top right side of your JSF page. When prompted to choose a component to Create choose Tables->ADF Read- Only Table7. In the Edit Table Columns dialog, check the three check boxes for Row Selection, Sorting, and Filtering, and click OK
  17. 17. 8. Drag the DepartmentsView1  EmployeesView3 data control again but this time into the Tab on the bottom right side of your JSF page. When prompted to choose a component to Create choose Form- >ADF Form9. In the Edit Form fields dialog, a. Change the Display Labels from <default> to appropriate labels as follows: i. Employee ID ii. First Name iii. Last Name iv. Email v. Phone Number vi. Hire Date vii. Job ID viii. Salary ix. Commission Percent x. Manager ID xi. Department ID b. Check the Include Submit Button check box c. Click OK
  18. 18. 10. Your JSP should look like the image below11. Click the Save All icon on the JDeveloper menu bar to save your workAt this point, you have completed building the ADF application with master-detail relationship views. In thenext lab we will establish a connection to a pre-installed local WebLogic Server and deploy and run this ADFapplication.
  19. 19. LESSON 2 - DEPLOYING & RUNNING ADF APPLICATION ONWEBLOGIC SERVERSummary:This exercise will walk you through the steps of establishing a server connection to the local WebLogic Server wewill deploy the application to, modifying the application and project properties so that the ADF applicationcreated in Lab 1 can be run on the WebLogic Server from JDeveloper.Activity Steps:Step A: Establishing a connection to WebLogic Server from JDeveloperWe will establish a connection to WebLogic Server in JDeveloper so that you can stop and start WebLogic Serverfrom JDeveloper. Note that once a connection is created to WebLogic Server, you can deploy any JEE applicationto that WebLogic Server from JDeveloper. 1. Open the Application Server Navigator by clicking on View  Application Server Navigator from the JDeveloper menu 2. In the Application Server Navigator, right-click on the Application Servers and select New Application Server… 3. On the Usage screen of the New Application Server wizard, select Integrated Server, and click Next
  20. 20. 4. On the Name and Domain screen of the New Application Server wizard, enter the following: a. Name: testdomain_wls11gserver
  21. 21. b. Check the Let JDeveloper manage the lifecycle for this Server Instance checkbox NOTE: The Domain Directory and Server Instance fields will not be enabled until after you check the Let JDeveloper manage the lifecycle for this Server Instance checkbox.c. Click on the icon next to the Domain Directory text box to browse to the /home/oracle/Oracle/JDev11113/user_projects/domains/testdomain directory, and click Select
  22. 22. d. Click on the icon next to the Server Instance text box to browse to the /home/oracle/Oracle/JDev11113/user_projects/domains/testdomain/servers/AdminServer directory, and click Selecte. Once all the fields have been configured as shown below, Click Next
  23. 23. 5. On the Authentication screen of the wizard, enter the following values and click Next a. Username: weblogic b. Password: welcome1 NOTE: Use the User Name and Password used during the Domain Configuration lab.6. On the Configuration screen of the wizard, enter the following values and click Next a. WebLogic Hostname (Administration Server): localhost b. Port: 7001 c. SSL Port: 7002 d. Always use SSL: Unchecked e. WebLogic Domain: testdomain7. On the Test screen of the New Application Server Wizard, click Next Note: If tested, the connection to the application server will fail because it is not running
  24. 24. 8. On the Finish screen of the New Application Server Wizard, click Finish
  25. 25. 9. Once you click Finish in the previous step, the new application server configuration (testdomain_wls11gserver) should appear in your Application Server Navigator screenAt this point you have configured a connection to the testdomain WebLogic domain and the WebLogicServer instance in the testdomain.
  26. 26. Step B: Modifying ADF Application & Project Properties to use testdomain_wls11gserverIn the next few steps we are going to modify the properties of the ADF Application so that we can deploy theADF application to the WebLogic Server connection that we established.Additionally, we will also modify the Project Properties of our Model to ensure that the database connectioninformation is properly deployed to WebLogic Server. 1. In the JDeveloper menu, click on Application  Application Properties 2. In the Application Properties dialog, click on Run, and from the Bind to Integrated Application Server drop down, select testdomain_wls11gserver, and click OK 3. In the Application Navigator panel, browse to Model  Application Sources  demo.model AppModule AppModule.xml 4. Right-click on AppModule.xml and select Open AppModule
  27. 27. 5. In the AppModule panel, select Configurations6. In the Configurations panel, select the AppModuleLocal configuration and click on the edit icon ( )
  28. 28. 7. In the Edit Business Components Configuration dialog, change the Connection Type to JDBC DataSource, and click OK 8. Repeat steps 6 & 7 for the AppModuleShared configuration 9. Click the Save All icon on the JDeveloper menu bar to save your workStep C: Running the ADF ApplicationNow that we have created the ADF application (in Lab 1) and configured the application and project to workwith the testdomain, we can run the ADF Application and go through some of its functionality. 1. In the Application Navigator, right click on the ViewController  Web Content  DeptEmpPage.jspx page, and choose Run ( )
  29. 29. 2. Since this is the first time the JSP page is being run, JDeveloper will do several things: a. Compile the HRSystem application b. Start the WebLogic Server in the testdomain c. Deploy the compiled HRSystem application d. Launch your browser to display the JSP page that we created You will know that everything went smoothly when the JSP page appears in your web browser. Additionally, you can verify the following messages in your Message log: Also, the Running: testdomain_wls11gserver tab will show System Out messages associated with WebLogic Server:3. Once the JSP page opens in your web browser, using the splitter resize the page area to display the data of the department. Then use the Next button to scroll through the departments. Notice that the data for the employees changes accordingly in the table and the Form beneath it.
  30. 30. 4. Try to update the Hire Date field for one of the employees with an invalid date such as 11/11/123 and notice the error message when you try to leave the field5. Browse to department 50 and notice that you can now scroll the data in the employees table. Click on one of the column header in the table to sort the data in the table
  31. 31. 6. Click a column heading in the table and drag it to reposition the column in the table7. In the Filter field above the LastName column type B% and hit Enter to filter the table to show only employees whose name begins with B8. Play with the other menu and buttons of the table to see additional functionality available on the JSP page Notice that by using the ADF components such as panel collection, panel splitter, panel tabbed, ADF read-only forms, etc. you get very rich out-of-the-box capabilities for which you didn’t have to write any code. For example: a. Resizing various areas within the page b. Collapsing and restoring panels c. First, Previous, Next, Last browsing of database information d. Master-Detail view updates e. AJAX capabilities where only relevant information is refreshed f. Filtering, column reordering, column sorting, column selection capabilities in the gridAt this point we have completed the creation of a database-driven JEE application with a rich, AJAX-enableduser interface and deployed it to a local instance of WebLogic Server that we configured.In the following lessons, we will continue to build on this base application and learn more about developingapplications using JDeveloper and WebLogic.
  32. 32. LESSON 3 – ADF DATA VISUALIZATION COMPONENTSSummary:In this lab you are going to enhance your JSF page by changing the table of employees on our page to add theability to do column selection and bind the business components to a graph representation to the userinterface. Youll do this with simple drag and drop operations - behind the scene the ADF Model layer takes careof this binding for you.Activity Steps:Summary:In this lab you are going to enhance your JSF page by changing the table of employees on our page to add theability to do column selection and bind the business components to a graph representation to the userinterface. Youll do this with simple drag and drop operations - behind the scene the ADF Model layer takes careof this binding for you.Activity Steps: 1. Back in JDeveloper select the Employees Table in the JSF page design editor or in the structure pane. Set the Column Selection Property of the table to Single. Next well add a graph representation of the data to our page - this is done using the ADF Data Visualization set of JSF components. Right click the new Departments accordion and choose Insert After Show Details Item - Departments -> Show Detail Item. This adds one more accordion to your page. Change its Text property to “More Info”. In the Design Editor click the More Info accordion to expand it. Then drag the EmployeesView3 data control into the More Info accordion. When prompted to choose a component to Create choose Graph....
  33. 33. The graph component is one of the ADF Faces Data Visualization components. The Graph can bedisplayed as static PNG image or an interactive Flash component. You can control these behavioursthrough the properties of the graph component. If there isn’t a Flash plug-in in the target browsers, forexample, you should select PNG format instead of the Flash default.In the Component Gallery Dialog choose Pie from the list of graphs on the left and Pie again as a graphtype. In the bottom pane, select the third Quick Start Layout.Then click the OK button.In the Create Pie Graph dialog choose Salary for the pie list and drag and drop LastName for the slices.
  34. 34. Then click the OK button.Select the dvt:pieGraph from the structure paneIn the Property Inspector, note that you can change the Image -> ImageFormat property to “PNG”instead of the default of “Flash”. This may be necessary if the Adobe Flash Player isn’t installed in thetarget client machines. We are not going to change this in the lab because we have the FlashPlayerinstalled in the Mozilla Firefox browser.Click the Save All icon on the JDeveloper menu bar to save your work.Right click within the page and select Run from context.
  35. 35. Browse to department 30. Because you set the column selection to single, note the additional behaviorsfor your table that are available once you choose a column - such as Freeze and Wrap. Select a column,then click the Freeze button. Now use the horizontal scroll bar to view the right most columns.Browse to department 30 then, expand the More Info accordion and note the graph and the pop-up itdisplays when you hover over it with your mouse.
  36. 36. When done, close the browser and return to JDeveloper.You are now completed with Lab 3: ADF Data Visualization Components
  37. 37. LESSON 4 – CREATING MORE COMPLEX BUSINESSCOMPONENTSSummary:In this section well add a new, more complex, Business Service to our application that will display a subset ofthe fields from the Employees table, along with the department name from the Departments table. Well alsoadd calculated fields. We’ll also create and use a List of Values for the JobIDs.Oracle ADF Business Components allows you to create such complex updateable components in a declarativeway.Activity Steps: 1. In the Application Navigator right click the demo.model package and choose New View Object. In the Name dialog update the Name field to be EmpDetails and keep the default type of “Updateable Access Through Entity Objects”. Click the Next button. In the Entity Objects dialog first select Employees and shuttle it to the right, and then select the Departments entity and add it to the right hand selection.
  38. 38. Note that only the Employees entity has the updateable checkbox checked - the Departments entity isused to read data only.Click Next.In the Attributes dialog shuttle the following Employees attributes to the right:• EmployeeId• FirstName• LastName• Salary• HireDate• JobIdAnd from the Departments entity shuttle the following attributes to the right:• DepartmentID• DepartmentNameAt this stage you can click the Finish button to complete the view object creation.Next we are going to see how to add a calculated attribute to our object - well add an attribute that willshow the yearly salary.
  39. 39. In the EmpDetails.xml editor switch to the Attributes section and click the Add button to add a newattribute.In the New View Object Attribute dialog update the following fields: Field Value Name YearlySalary Type Number Value Type Expression Value Salary * 12Click the OK button.In the next couple of steps well show how to add a list of values to a field based on a set of valuesstored in another table. In this case well add a list of values for possible job titles from the jobs table.In the EmpDetails.xml editor switch to the View Accessors section click the Add button to add a newview accessor.
  40. 40. In the View Accessors dialog shuttle the JobViews to the right.Click the OK button.In the EmpDetails.xml editor switch to the Attributes section, select the JobId attribute and in the List OfValues section click the Add button.
  41. 41. In the List of Values dialog select JobsView1 for the List Data Source field, and JobId as the List Attribute.Still in the List of Values dialog Click the UI Hints tab and choose Input Text with List of Values as theDefault List Type and then shuttle the Job Title attribute to the right.Click the OK button.Now we need to add the new object that we created to the data model we exposed to the userinterface developers.In the Application Navigator double click the AppModule to open it for editing and choose the DataModel section of the editor.
  42. 42. Click the EmpDetails view object and shuttle it to the right.In the Application Navigator Right-click AppModel and select Run to invoke the application moduletester. This is a small Swing based application that allows you to test the ADF Business Components youhave just created.Double click the EmpDetails view object to test the functionality you defined.Invoke the list of values for the JobId to choose a new job.
  43. 43. The selected job gets populated.Close the Business Components Tester window without committing the changes and back in JDeveloper,close the AppModule.xml, EmpDetails.xml and DeptEmpPage.jspx tabs. Click the Save All icon on theJDeveloper menu bar to save your work.
  44. 44. LESSON 5 – CREATING MULTIPLE PAGE WEBSITES –PAGE FLOWSSummary:Web applications usually have more than one page in them. In the next section you are going to add anotherpage to your application and use the ADF Task Flow to define the navigation rules between the two pages.Activity Steps:To add a page flow and navigate between pages, perform the following steps: 1. In the Application Navigator under the ViewController project locate the file adfc-config under the page flows node. Double click it to open it in the editor. This is where we define navigation in our application. Drag and drop the DeptEmpPage.jspx file from the application navigator into the empty adfc-config diagram. From the Component Palette drag and drop a View component into the adfc-config diagram, and rename it to query. This is going to be a new JSF page that well create in a minute.
  45. 45. From the Component Palette choose a Control Flow Case and then click on the DeptEmpPage and drag aline to the query page.Name this line goQuery.From the Component Palette choose another Control Flow Case and then create an opposite flow fromthe query page to the DeptEmpPage. Name this flow backDouble click the query view in the diagram to create the new page. Using the Page Template option,select the Oracle Three Column Layout one in the Create JSF page dialog.
  46. 46. Click OK.In the Structure pane, select the end and start facets from the template and right click to delete them.In the Data Controls pane, click the Refresh button to have EmpDetails1 appearing in the list.Locate the EmpDetails1 data control expand it and expand the Named Criteria node under it. Select theAll Queriable Attributes and drag it into the center area of the new query.jspx page.When prompted to choose a component to Create choose Query -> ADF Query Panel.
  47. 47. In the Data Controls accordion select the EmpDetails1 data control and drag it into the center area ofthe page below the query component.When prompted to choose a component to Create choose Form->ADF Form.In the Edit Forms Details, check both the Include Navigation Controls and the Include Submit Button.
  48. 48. Click OK.In the structure pane locate the Submit button, right click it and choose Insert after af:command:Button- Submit -> Button.Using the property inspector change the Text of the new button to be Back and for the Action propertyselect back from the drop down list. This will cause the button to perform the navigation you defined inthe page flow.
  49. 49. Next well add transaction operations to the page to allow you to commit and rollback changes. In theData Controls Palette expand the application module level Operations node to locate the commit androllback operations. Drag the Commit operation into the structure pane before the First Button. Whenprompted for a drop target choose ADF ButtonRepeat the same steps for the Rollback operation.
  50. 50. In the Property Inspector, for the Rollback and for the Commit buttons, expand the Behavior section andset the Disabled property to default.If youll maximize the design editor at this stage by double clicking the query.jspx tab, your page shouldlook like this:Switch back to editing the DeptEmpPage.jspx by clicking on its tab or opening the file from theApplication Navigator.A quick way to navigate to this or any other file is using the global find box at the top right of JDeveloperand typing the file name there,
  51. 51. Then just click the file name to open it in the editor.In the page design, expand the Departments accordion. From the Component Palette, choose a Buttoncomponent and drag it into the Departments accordion between the First and Previous buttons.Alternatively you can select the First button by clicking on it, then right click that same button andchoose insert after->button to add the new button.Using the property inspector change the Text of the button to be Query and for the Action propertytype goQuery or select it from the drop down list if available (NOTE: in some cases it will not be in thepulldown menu). This will cause the button to perform the navigation you defined in the page flow.
  52. 52. Click the Save All icon on the JDeveloper menu bar to save your work, and then right click theDeptEmpPage.jspx page and choose Run.When the page appears in your browser click the Query button to navigate to your new page.In the new Query page, click the magnifying glass icon next to the JobID field to bring up a search form.Search for Jobs whose jobTitle begins with A%.
  53. 53. Choose the Accountant title and click OK.Now click the Search button in the Query page to return the results in the form below.You can continue playing with the form saving your query criteria, creating more complex queries andupdating data for employees. Note how this form displays a view of the data that matches the definitionin the view object you created - including information for Department name as well as a list of values forthe Job id.You can also make changes to the data and commit and rollback your transaction as needed.
  54. 54. Close your browser window.
  55. 55. LESSON 6 – CREATING JEE5 STATELESS SESSION EJBSSummary:In this lab, a new project will be added to the HRSystem application which will encapsulate the business logicrequired for checking the credit for the employees. This business logic will be implemented as a distributedservice using a JEE5 Stateless Session EJB. Stateless Session EJBs are often used in practice to encapsulatebusiness logic because they scale very well, are well known, and are supported by all main-stream applicationservers such as WebLogic.Activity Steps: 1. Select File -> New -> General -> Applications -> Generic Application 2. Name the Application “CreditScoreApp” then select “Next” 3. Name the project “CreditScore” and shuttle over “EJB” in the Project Technologies tab, then select “Next”
  56. 56. 4. Take the defaults on the Configure Java Settings page then select “Next”5. In the “Configure EJB settings” page, keep the selection of “Enterprise JavaBeans 3.0 (Java EE 5.0)” and the “Using annotations” radio button for meta-data preferences. Select “Session Bean” from the Invoke Wizard pulldown menu, then select “Finish”
  57. 57. 6. Change the name of the EJB to “CreditScore” and keep the other default settings then select “Next”: In the Class Definitions screen take the default Bean Class and Source Directory then select “Next”
  58. 58. In the next screen, you can see that the wizard gives the option of either creating a Remote Interface, aLocal Interface or both. We will create both so you can see the artifacts which are created, even thoughthis session bean will not be called from a remote application.Keep the default settings then select “Next”Review the settings for the Stateless Session EJB then select “Finish”
  59. 59. The CreditScoreApp Overview page will be displayed so you can see an overall view of the EJB7. Open up the editor for the bean class “CreditScoreBean.java” so we can explore the annotations automatically setup for a stateless EJB3.0 EJB by the creation wizard. Select the plus sign in front of the “@annotations…” Note the annotations used for defining a stateless EJB3.0 EJB – @Stateless, @Remote and @Local: @Stateless(name = "CreditScore", mappedName = "HRSystem-CreditScore-CreditScore") @Remote @Local8. Next we will create a new method to implement the guts of the business logic and actually get the credit score. This business logic is a mock – in practice, a real service interface would be written that would possibly interface with a credit agency such as Experian. Following is a code-block that will return a credit score based on the last character of the employee ID number passed in: public int getCreditScore(String empId) { int score = 400; // initialize to extremely poor credit switch (empId.charAt(empId.length()-1)) { case 1: case 2: case 3: score = 500; // poor credit score break; case 4: case 5: case 6: score = 600; // average credit score break; case 7: case 8: case 9: score = 700; // good credit score } return score; }
  60. 60. 9. Now we need to expose this new method from the EJB’s remote and local interfaces. Open up the files “CreditScore.java” and “CreditScoreLocal.java” and add the following method definition of the “getCreditScore(String empId)” method to both interfaces which are currently empty. int getCreditScore(String empId); Select the Save All icon10. We are now done creating our Stateless Session EJB. Next we want to deploy this to WebLogic so we can test it.
  61. 61. First, we need to create a new deployment profile. A deployment profile tells JDeveloper how topackage up the application and which artifacts will go into it.Right-click on the “Credit Score” project and select “Deploy” then select “ ”Select “EJB Jar File”, then “OK”Name the deployment profile “CreditScore_EJB”, then select “OK”Finally, select “OK” again to dismiss the deployment profile dialog.
  62. 62. Select “OK” again to dismiss the Project Properties dialog. Select the Save All – now we’re ready to deploy11. Now we will deploy the CreditScore EJB using the newly created deployment profile. Right-click on the CreditScore Project and select Deploy -> CreditScore_EJB Next, select “Deploy to Application Server” as the Deployment Action:
  63. 63. Select “testdomain_wls11gserver” from the list of available WebLogic server instances. Make sure thatthe “Overwrite modules of the same name” checkbox is selected, then select “Next”A Terminal will open and start the WebLogic Server we will deploy our EJB to. Leave that window openand go back to JDeveloper to restart the deployment process from step 11.Keep the default WebLogic options, then select “Next”Finally, review the deployment settings for the CreditScore EJB, then select “Finish”
  64. 64. Check that the deployment finished successfully in the “Deployment” tab in JDeveloper12. You can also choose to review the WebLogic console to see that this deployment was successful. Open the WebLogic console in the browser at http://localhost:7001/console13. Select “Deployments” in the left-hand navigation, then expand the “CreditScore_EJB” in Deployments – this will show you the structure of the EARfile that was just deployed by JDeveloper into WebLogic14. Now, we want to test the EJB that we just deployed. One easy way to do this is to use the built-in tooling within JDeveloper to create an EJB test client. Right-click on the “CreditScoreBean.java” file and select “New Sample Java Client…”
  65. 65. This will bring up a small dialog asking which project you would like to put the test client in, or if you’dlike to create a new project. Don’t create a new project, but we’ll add this test client to the current“CreditScore” project. Set the “Application Server Connection” to “testdomain_wls11gserver” from thatpulldown menu. Select the “OK” button.“CreditScoreLocalClient.java” file will be created in the CreditScore project and opened up in the editor.This test class will have a “main(String args[])” method as the test driver and another utility methodcalled “getInitialContext()” which will lookup WebLogic’s JNDI tree context so the new EJB can be lookedup easily from the main method.Modify the CreditScoreLocalClient.java so that it will cycle through several employee IDs and make surethat the business logic within the Stateless Session EJB is working correctly. A suggestion is to add thefollowing lines after the context.lookup method call: for (int empId = 100; empId < 110; empId++) { int empCreditScore = creditScore.getCreditScore(Integer.toString(empId)); System.out.println("Credit Score for Employee ID " + empId + " from the CreditScore Stateless EJB is: " + empCreditScore); }Next, select the Save All icon and then run the new test client application.
  66. 66. Right-click on CreditScoreLocalClient.java and select RunYou should now see the output from the test client program which has successfully called the newStateless Session EJB with several different employee ID and returned different credit scores:
  67. 67. LESSON 7 – CREATING JAX-WS WEB SERVICESSummary:In this lesson, the Stateless EJB just created in the previous lab will be wrapped with a Web Service to show abottom-up Web Service design. We will also show top-down web-service development by providing a WSDLwhich defines a new web service which will be created based on that WSDL as a base design that we will thenimplement the business logic for.Activity Steps:Step A: Creating a Bottom-up Web Service 1. One simple way to create a bottom-up web service is to use the built-in tooling from JDeveloper to expose an existing Java Class or EJB as a web service. Right-click on the “CreditScoreBean.java” and select “Create Web Service…” 2. Take the default web service name “CreditScoreBeanService” and the default Port Name “CreditScoreBeanServicePort”. Do not select the “Add SEI” button (Service Endpoint Interface – part of the JEE5 specification). Select “Next”
  68. 68. 3. On the Message Format page, select “SOAP 1.2 Binding” and keep the default “Document/Wrapped” SOA Message Format. Do not select the “Enable MTOM” checkbox (Message Transmission and Optimization Mechanism) as the binary encoding style. When MTOM is enabled, on the wire, the base64Binary content will be automatically put in a MIME attachment part in binary form.4. On the “Methods” page, select the only method available which is the getCreditScore() method then select the “Finish” button as we’ll take the defaults on all subsequent wizard screens:
  69. 69. 5. Open up the “CreditScoreBean.java” file and note the new annotations that have been added giving this EJB a web service front-end now! Outside of the 2 new annotations (@WebService and @BindingType) and some new import statements, the Stateless Session EJB remains a POJO (Plain Old Java Object).6. Before testing, we need to undeploy the new CreditScore EJB application because we are going to now use the WebServices deployment plan that was created. If we don’t do this, we will get naming conflicts from WebLogic JNDI (Java Naming and Directory Interface) if we try to deploy the same EJB twice. To undeploy, open up the WebLogic console at http://localhost:7001/console and login as weblogic/welcome1. Navigate to “Deployments” on the left-hand side navigation. Next, select the “CreditScore_CreditScore_ejb1” application checkbox then select the “Stop” -> “Force Stop Now”. The state of the deployment will be changed from “Active” to “Prepared”. In the prepared state we can delete the deployment. Select the application checkbox again then select “Delete”. The application will now be deleted. In addition to undeploying the old EJB, we want to remove the old deployment descriptor for the plain EJB – now that we have added the WebService to the EJB, the old deployment descriptor won’t work because it doesn’t include the right libraries.7. In order to delete this old deployment descriptor, Right-click on the “CreditScore” project and select “Project Properties”. Select “Deployment” in the left-hand navigation, then select “CreditScore_EJB” and select the “Delete” button. You should now only have the “EjbWebServices (EJB JAR File)” deployment plan for the CreditScore project. Select “OK” to dismiss the Project Properties dialog.
  70. 70. 8. Now, let’s test the new web service interface created for this EJB. Back in JDeveloper, right-click on the CreditScore project and select Deploy -> EjbWebServices… and deploy the project to the testdomain_wls11gserver as we have done before. NOTE: The “EjbWebServices” deployment plan was created automatically when we went through the Create WebService wizard. After the project has been deployed, we can access the WebLogic Test Client from the WebLogic console. Open up the WebLogic console with the following URL: http://localhost:7001/console and login with credentials “weblogic/welcome1” Go to the Deployments in the left-hand navigation then expand the “WebServices_CreditScore_CreditScore” application, then select the “CreditScorebeanService”
  71. 71. Then select the “Testing” tab:Expand the “CreditScoreBeanService” node to expose the test point for the web service:Selecting the link “Test client” will deplpoy and open up the Weblogic Test Client.Enter “000” as the getCreditScore input String argument, then select the “getCreditScore” buttonExamine the Service Request and Service Response payloads shown in the getCreditScore Request Detailsection. Note that the return value is 400 just as it was with the Stateless Session EJB test client.
  72. 72. You can test out different values of the input argument by selecting the “Show Operations” button , entering a new input value and re-selecting the “getCreditScore” button again. Remember that the business login in the Stateless Session EJB will determine the credit score based on the last digit of the employee ID, so this digit is what you will want to vary on the input argument. Each invocation of the service will be logged in the “Message Log” on the left-hand side of the test client window.Step B: Creating a Top-Down Web ServiceOracle JDeveloper support multiple ways of creating Web Services. JDeveloper wizards include the ability tocreate Web Services from EJBs, POJOs (Plain Old Java Objects), Database DML and PL/SQL, JMS and others. Inthis lab we’ll use what’s often described as a best practice: Top-Down development. Using this method we startby using WSDL and let JDeveloper generate the Java Web Service from there. All we have to do from that pointis include our service specific code deploy to the application server. 1. We will be creating a TotalSalary service which will take a department number as input and return the sum of all the salaries in a department. Select File -> New -> General -> Applications -> Generic Application 2. Name the Application “TotalSalaryApp” then select “Next”
  73. 73. Name your new project “TotalSalaryService” and then select “Web Services” in the Project Technologies list to shuttle over to the selected set of technologies. “Java” will be automatically included along with “Web Services”. Then select “Finish” to take the default Project Java Settings. The TotalSalaryApp Overview will be shown in the editor pane.3. Right-click on the TotalSalaryService project and select “New”. In the New Gallery, select Business Tier - > Web Services -> Java Web Service from WSDL then “OK”
  74. 74. 4. The Create Java Web Service from WSDL wizard will now come up. Select “Next” on the Welcome page. On the “Select Deployment Platform” page, select “Java EE 1.5 with support for JAX-WS Annotations” then “Next” Next, browse to the WSDL document located in the “/home/oracle/Workshop/Resources/” directory of the workshop – it is named “TotalSalaryService.wsdl”. Ensure that you select a Service Type of “Java” and make sure that the “Copy WSDL Locally” checkbox is selected, then select “Finish”
  75. 75. 5. At this point JDeveloper generates the java classes based on the WSDL definition. It will be our responsibility to define what the web service will actually do. The WSDL editor will be opened up in the design pane of JDeveloper. Review all the files that were generated from the WSDL definition. From the Application Navigator Projects tab Right-click on the TotalSalaryPortImpl.java source file under “Open”.6. Into this java code we will copy and paste some pre-created source to define what this Web Service does. In the totalSalary method, replace the line that says “return null;” with the following lines: String totalSalary = "100000"; switch (DepartmentId.charAt(0)) { case 1:. case 2: case 3: totalSalary = "200000"; // poor credit score break; case 4: case 5: case 6: totalSalary = "300000"; // average credit score break; case 7: case 8:
  76. 76. case 9: totalSalary = "400000"; // good credit score}return totalSalary;This business logic is similar to the Stateless Session EJB we created to get the credit score – notpractical, but it acts as a stub for real business logic you could implement to read the salaries from theHR database.You are now complete with your Top-Down Web Service – it was that simple!Next we want to test this new web service. This can be done just like the bottom-up web service.First, deploy the TotalSalaryService to the testdomain_wls11gserver. Right-click on theTotalSalaryService project, select Deploy -> WebServices… then select the testdomain_wls11gserverapplication server as a deployment target.After the web service has been deployed successfully, go to the WebLogic console and expand thenewly deployed application “TotalSalaryApp-TotalSalaryService-context-root” deployment, then selectthe “TotalSalaryService” web service.Once again, navigate to the “Testing” tab, expand the “TotalSalaryService” node, then select the “Testclient” link to launch the integration WebLogic web services test harness.
  77. 77. Once the test client comes up in the web browser, input a value of “800” into the DepartmentIdInfo,then select the “TotalSalary” button and see that a value of “400000” is returned.You can test out different values of the input argument by selecting the “Show Operations” button , entering a new input value and re-selecting the “TotalSalary”button again. Each invocation of the service will be logged in the “Message Log” on the left-hand side ofthe test client window.
  78. 78. LESSON 8 – ADDING THE NEW SERVICES INTO THEADF APPLICATIONSummary:In this lab, we will take the Stateless Session EJB and WebService created in the previous labs and incorporatethese services into the existing ADF application.Activity Steps:Step A: Exposing the CreditScore Stateless Session EJB 1. First, we will add the Stateless Session EJB to the ADF-based application we built in labs 1 - 5. JDeveloper makes this easy by giving the ability to create an ADF Data Control. It is most straight- forward to create the ADF Data Control from the Web Service we put in front of the EJB we created. Right-click on the ViewController project in the HRSystem application and select New -> “All Technologies” Tab -> Business Tier -> Data Controls -> Web Service Data Control. Name the new data control “CreditScoreDataControl”. Get the WSDL for the CreditScoreService from the WebLogic console. It is in the same place that you got the link for the test client. Right-click on the “WSDL?” link and select “Copy Link Location” so the value can be pasted into the Create Web Service Data Control wizard. Hit the <Tab> or <Return> so the wizard will introspect the WSDL and automatically select the one service that is available. Select “Next”
  79. 79. Shuttle the “getCreditScore” operation from the “Available” side to the “Selected” side then select“Next”Select the getCreditScore operation and verify that the Format for the response is XML
  80. 80. Don’t select any authentication for the endpointReview the settings for the data control, then select Finish
  81. 81. The Data Control will be created and will show up in the Data Controls view. We are now ready to add it to the HRSystem’s view2. Now, we will add another accordion panel under Departments where we’ll create a form to call our Stateless Session EJB Data Control. In the HRSystem Application, Right click the Departments accordion and choose Insert After Show Details Item - Departments -> Show Detail Item. This adds another accordion to your page. Change its Text property to “Employee Credit Score”.3. In the Design Editor click the new Employee Credit Score accordion to expand it. Then from the HRSystem application, drag the CreditScoreDataControl -> getCreditScore(String) data control into the Employee Credit Score accordion. When prompted to choose a component to Create choose ADF Parameter Form.... Change the Display Label for the arg0 Value Binding to “Employee ID” then select the “OK” button to create the form.
  82. 82. Next, drag and drop the Data Controls -> CreditScoreDataControl -> getCreditScore(String) -> Integer return value just after the “getCreditScore” button in the designer. Now select Create -> Text -> ADF Output Text w/ Label. This will create an output textbox with the results of the call to the Data Control to get the credit score from the EJB.4. Change the label of the output textbox to “Credit Score” from it’s default value of #{bindings.Return.hints.label}5. Select the Save All icon and then Run the “DeptEmpPage.jspx” Note: If you get a “Port Conflict Detected” message, click “Cancel”, terminate the running WebLogic Server instance by selecting the Terminal where it is running and pressing Ctrl-C, and repeat the previous step.
  83. 83. 6. Expand the “Employee Credit Score” accordion and test different Employee IDs to verify it’s hitting the backend EJB through the Web Service: Use the following IDs to ensure that the Stateless Session EJB is getting called correctly: Employee ID Credit Score Result Employee ID Credit Score Result 000 400 111 500 444 600 777 700Step B: Exposing the TotalSalary Web ServiceThe TotalSalary Web Service is exposed in the same way that the CreditScore EJB was. 1. First, create a Data Control by Right-clicking on the HRSystem application, the selecting New -> “All Technologies” Tab -> Business Tier -> Data Controls -> Web Service Data Control
  84. 84. Name this Data Control “TotalSalaryDataControl”. Copy the WSDL URL from the WebLogic console in asimilar manner as was done for the CreditService Web Service and paste the WSDL into the URL textbox.Hit <Return> or <Tab> and the WSDL will be introspected and the service operation will be populated.Select the “Next” buttonShuttle the TotalSalary operation from the “Available” to the “Selected” column, then select “Next”
  85. 85. Select the TotalSalary operation and ensure that the response format is XML then select “Next”For this lab, don’t select any authentication for the operation endpoint. Select “Next”
  86. 86. Review the configuration and select “Finish” to create the new Data Control for the TotalSalaryService2. Now, we will add another accordion panel under Employee Credit Score where we’ll create a form to call our new Web Service Data Control. In the HRSystem Application, Right click the Employee Credit Score accordion and choose Insert After Show Details Item - Employee Credit Score -> Show Detail Item. This adds another accordion to your page. Change its Text property to “Total Department Salary”.3. In the Design Editor click the new Total Department Salary accordion to expand it. Then from the HRSystem application, drag the TotalSalaryDataControl -> TotalSalary(String) data control into the Total Department Salary accordion. When prompted to choose a component to Create choose ADF Parameter Form....
  87. 87. Change the Display Label to “Department ID”, then select “OK”4. Finally, drag and drop the Data Controls -> TotalSalaryDataControl -> TotalSalary(String) -> String return value just after the “TotalSalary” button in the designer. Now select Create -> Text -> ADF Output Text w/ Label. This will create an output textbox with the results of the call to the Data Control to get the credit score from the EJB.
  88. 88. 5. Change the label of the output textbox to “Total Salary” from it’s default value of #{bindings.Return.hints.label}6. Select the Save All icon and then Run the “DeptEmpPage.jspx”7. Test the application by expanding the “Total Department Salary” accordion and test different Department IDs to verify it’s hitting the backend Web Service: Use the following IDs to ensure that the Web Service is getting called correctly: Department ID Total Salary Result 000 100000 111 200000 444 300000 777 400000
  89. 89. Note: it is possible that in the WebLogic console (in JDeveloper “Running: testdomain_wls11gserver –Log” tab) there will be errors for the Web Services Manager (WSM) – these are OK because WSM hasn’tbeen setup and these can be ignored.<Error> <oracle.wsm.resources.policymanager> <WSM-02054> <Failure in looking up EJB componentPolicyAccessService#oracle.wsm.policymanager.ejb.IStringPolicyAccessServiceRemote.>You have now completed integrating the new services into the HRSystem application as shown below:
  90. 90. LESSON 9 – DATA VALIDATION (OPTIONAL)Summary:This exercise will enhance the application that we have created. In this lab you refine your business services byadding validation rules, formatting and default values. The following enhancements will be made:  Data input validation rules will be configured  Data input format types will be configuredActivity Steps: 1. Re-deploy the HRSystem application onto WebLogic (if it isn’t still running from the previous lab). Notice that the Salary field does not have field validation. Change the salary for any employee to a negative value. Click on the Submit button and notice that this negative value is persisted to the database without any errors. The lack of this data integrity enforcement at the presentation layer can cause incorrect behavior and dirty (invalid) data in the database. We will add validation to this field in order to prevent this situation from occurring. Let us now modify the HRSystem to add validation rules and fix this problem. 2. In the Application Navigator locate the Employees entity object in the Model project. “Model” -> “Application Sources” -> “demo.model” - double click it to open it for editing.
  91. 91. 3. In the Employees.xml window, click the Attributes node and locate the Salary attribute, and click it. Scroll down in the page to the validation section and click the Add icon to add a new Validation rule.4. In the Add Validation Rule dialog choose Range from the Rule Type drop down list. Note the various other types of rules you can define here. In the Operator drop down keep the Between value, and type 0 for the minimum value and 99000 for the maximum value fields.
  92. 92. 5. Click the Failure Handling tab to define an error message that will appear when the validation fails. In the Message Text field type an error message like "Salary out of range: 0 to 99,000". Click OK.6. Next well add a default value to the hired date field - so when we create a new employee well have todays date as the default value. Back in the Employees.xml window, locate the HireDate attribute, and click it. If not already there, bring up the properties window using CTRL+Shift+I. In the Value section of the properties, locate the Default Value Type property and choose Expression, then set the Default Value property to adf.currentDate. This will make sure the default value for a new record is set to todays date.
  93. 93. 7. You can also specify UI Hints for attribute to control how they will display by default in the forms and pages that will use them. In our case well add a default format mask for the Hired date field you can also specify labels and tooltip helps here. In the UI Hints section of the property inspector locate the Format Type property and select Simple Date. Locate the Format property and type MM/dd/yyyy.8. You can now run the Application Module Tester again (right click Run on the AppModule) to check the new validation, default value for new record and UI hint you just added. Click on any of the EmployeesView in the tester.
  94. 94. 9. Enter an out of range value as salary to check validation and the error message. Click the Insert Record button and see the default value you defined appear for the HireDate field. Close the Tester.
  95. 95. Click the Save All icon on the JDeveloper menu bar, or select File | Save All from the menu.10. Redeploy the application and test the Salary field again to see how the validation rule works. Note that the validation error will highlight the field in red and give a pop-up with the error text that was entered in the Employee entity earlier: Try to update the HireDate field for one of the employees with an invalid date such as 11/11/123 and notice the error message when you try to leave the field. You are now completed with Lab 9: Data Validation (Optional)

×