SlideShare a Scribd company logo
1 of 95
Oracle ADF 11g Developer Lesson
Name – Rakesh Gujjarlapudi

Email Address – rakesh_gujj@yahoo.com
OVERVIEW
       Installing Oracle Express 10g Database
       Installing Oracle WebLogic Server 11g & JDeveloper 11g
       Creating a WebLogic Server 11g Domain

WebLogic Server 11g Info:
MIDDLEWARE_HOME=/home/oracle/Oracle/JDev11113
Configuration Wizard = ${MIDDLEWARE_HOME}/wlserver_10.3/common/bin/config.sh
Domain Home: /home/oracle/Oracle/JDev11113/user_projects/domains/testdomain
Admin Server Console: http://localhost:7001/console
User: “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/jdev
Lab Project Location = /home/oracle/jdeveloper/mywork/HRSystem

Oracle XE Info:
Database Version: 10.2.0 (10g)
Starting Oracle XE: /etc/init.d/oracle-xe start
Stopping Oracle XE: /etc/init.d/oracle-xe stop
User: sys / welcome1
User: HR / welcome1

JDK Info:
JDK1.6.0_22 – installed at: /usr/local/bin/jdk1.6.0_22
LESSON 1 – CREATING AN ADF APPLICATION
Summary:
This exercise will walk you through the steps of creating a rich internet application using Application
Development Framework (ADF) using JDeveloper. The purpose of this lab is to get you some familiarity with
JDeveloper and ADF. In this lab, we will create an ADF application that connects to a backend database and
retrieves information abbot departments and employees in that department. Additionally, the ADF application
will 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.html

Activity Steps:

Step A: Creating a New ADF Application and Business Components

When you work in JDeveloper, you organize your work in projects within an application. JDeveloper provides
several templates that you can use to create an Application and projects. The templates are pre-configured with
a basic set of technologies that are needed for developing various types of applications, and you create your
working environment by selecting the template that fits your needs. You can then configure it to add any other
technologies you plan to use. In the first section you are going to create a new Application using the Fusion
technology 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.

    1. Launch JDeveloper by double-clicking the desktop icon

        In JDeveloper, click on View ->Application Navigator




        In the JDeveloper Application Navigator, click New Application.
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 Finish




In the CheckList pane, click the Connect to a Database step




The step expands showing useful information such as prerequisites required for performing this task.
Click the Create a Database Connection button.
Specify the following properties for the new connection you are creating:
Connection Name: HRConn
Username: HR
Password: welcome1
SID: XE




Click the Test Connection button on the Create Database Connection dialog to verify that a successful
connection




Once done, click the OK button to exit out of the Create Database Connection dialog
Click the down arrow to collapse the Connect to a Database step




In the Checklist pane, set the status of the Connect to a Database step to Done
Click the Build Business Services step to expand it, then click the Go to Substeps button




In the subtask list, click the Create Entity Objects and Associations subtask




Click the Create Entity Objects and Associations button




In the Select Project for Action dialog, select the Model project
In the Initialize Business Components Project dialog, verify that the HRConn connection is already
selected




Click OK in the Initialize Business Components Project dialog
In the Entity Objects page, click the Query button to examine the data dictionary and see available
tables




Select the DEPARTMENTS and EMPLOYEES tables in the Available list, and click the right arrow          to
move your selections to the selected list.
NOTE: This step creates updateable Entity Objects based on the tables you chose.
Click Next to continue

In the Updateable View Objects dialog, move Departments (DEPARTMENTS) and Employees
(EMPLOYEES) to the selected list




NOTE: This step creates matching view objects DepartmentsView and EmployeesView to perform
queries on the entity object you created before.
Click Next to continue
In the Read Only View Objects dialog, click the Query button and then move JOBS to the Selected list




NOTE: This step creates a read only view object that queries the Jobs table
Click Next to continue

In the Application Module dialog, click Finish to create the business components in the Model project
In the Subtask list, click on the Close Step 3 button




        Set the status of the Build Business Services step to Done




Step B: Creating JSF Web pages
Having completed the creation of the business components (Model and View objects), we can now build the
user interface using JavaServer Faces (JSF), which is a standard Java EE technology that simplifies Web
development.
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. You'll also use a master-detail
relationship to display the information about employees in each department. To build the page you'll be using
the Oracle ADF Faces Rich Client Components - these components allow you to build Ajax-based rich Web UI
without writing low level HTML and Javascript code. The Web part of the application is developed in a separate
project called the viewcontroller project. This separation between the Model layer and the user interface makes
the business services more reusable.
    2. We'll 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
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, we'll delete the third one. Place your cursor in
   the right-most section called end and right click to choose Delete




6. In the Structure pane, with the af:pageTemplate selected, in the Property Inspector set the
   startColumnSize value to 350 to enlarge it




7. 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 page




8. Click the ShowDetails1 accordion that was created on the page, and in the Property Inspector change its
   Text property to Departments
9. From the Layout components, click-and-drag a Panel Splitter component onto the Center area of your
   page




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




11. 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
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 page




13. 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 Employee




14. Your page should look like the image below




15. Click the Save All   icon on the JDeveloper menu bar to save your work
Step C: Binding Data Controls to your JSF page
In the next few steps you are going to bind the business components you created to your user interface. You'll
do this with simple drag and drop operations - behind the scene the ADF Model layer takes care of this binding
for 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
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 Form




4. 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
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 you'll 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 Table




7. In the Edit Table Columns dialog, check the three check boxes for Row Selection, Sorting, and Filtering,
   and click OK
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 Form




9. 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
10. Your JSP should look like the image below




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

At this point, you have completed building the ADF application with master-detail relationship views. In the
next lab we will establish a connection to a pre-installed local WebLogic Server and deploy and run this ADF
application.
LESSON 2 - DEPLOYING & RUNNING ADF APPLICATION ON
WEBLOGIC SERVER
Summary:
This exercise will walk you through the steps of establishing a server connection to the local WebLogic Server we
will deploy the application to, modifying the application and project properties so that the ADF application
created in Lab 1 can be run on the WebLogic Server from JDeveloper.

Activity Steps:

Step A: Establishing a connection to WebLogic Server from JDeveloper


We will establish a connection to WebLogic Server in JDeveloper so that you can stop and start WebLogic Server
from JDeveloper. Note that once a connection is created to WebLogic Server, you can deploy any JEE application
to 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
4. On the Name and Domain screen of the New Application Server wizard, enter the following:
       a. Name: testdomain_wls11gserver
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
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 Select




e. Once all the fields have been configured as shown below, Click Next
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: testdomain




7. 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
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 appear in your Application Server Navigator screen




At this point you have configured a connection to the testdomain WebLogic domain and the WebLogic
Server instance in the testdomain.
Step B: Modifying ADF Application & Project Properties to use testdomain_wls11gserver
In the next few steps we are going to modify the properties of the ADF Application so that we can deploy the
ADF 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 connection
information 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
5. In the AppModule panel, select Configurations




6. In the Configurations panel, select the AppModuleLocal configuration and click on the edit icon (   )
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 work

Step C: Running the ADF Application

Now that we have created the ADF application (in Lab 1) and configured the application and project to work
with 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 ( )
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.
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 field




5. 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
6. Click a column heading in the table and drag it to reposition the column in the table




7. 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 B




8. 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 grid

At this point we have completed the creation of a database-driven JEE application with a rich, AJAX-enabled
user 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 developing
applications using JDeveloper and WebLogic.
LESSON 3 – ADF DATA VISUALIZATION COMPONENTS
Summary:
In this lab you are going to enhance your JSF page by changing the table of employees on our page to add the
ability to do column selection and bind the business components to a graph representation to the user
interface. You'll do this with simple drag and drop operations - behind the scene the ADF Model layer takes care
of 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 the
ability to do column selection and bind the business components to a graph representation to the user
interface. You'll do this with simple drag and drop operations - behind the scene the ADF Model layer takes care
of 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 we'll 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....
The graph component is one of the ADF Faces Data Visualization components. The Graph can be
displayed as static PNG image or an interactive Flash component. You can control these behaviours
through the properties of the graph component. If there isn’t a Flash plug-in in the target browsers, for
example, 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 graph
type. 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.
Then click the OK button.

Select the dvt:pieGraph from the structure pane




In 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 the
target client machines. We are not going to change this in the lab because we have the FlashPlayer
installed 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.
Browse to department 30. Because you set the column selection to single, note the additional behaviors
for 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 it
displays when you hover over it with your mouse.
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 BUSINESS
COMPONENTS
Summary:
In this section we'll add a new, more complex, Business Service to our application that will display a subset of
the fields from the Employees table, along with the department name from the Departments table. We'll also
add 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 declarative
way.

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.
Note that only the Employees entity has the updateable checkbox checked - the Departments entity is
used to read data only.




Click Next.

In the Attributes dialog shuttle the following Employees attributes to the right:
•       EmployeeId
•       FirstName
•       LastName
•       Salary
•       HireDate
•       JobId
And from the Departments entity shuttle the following attributes to the right:
•       DepartmentID
•       DepartmentName




At 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 - we'll add an attribute that will
show the yearly salary.
In the EmpDetails.xml editor switch to the Attributes section and click the Add button to add a new
attribute.




In the New View Object Attribute dialog update the following fields:

  Field          Value
  Name           YearlySalary
  Type           Number
  Value Type     Expression
  Value          Salary * 12




Click the OK button.

In the next couple of steps we'll show how to add a list of values to a field based on a set of values
stored in another table. In this case we'll 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 new
view accessor.
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 Of
Values section click the Add button.
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 the
Default 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 user
interface developers.
In the Application Navigator double click the AppModule to open it for editing and choose the Data
Model section of the editor.
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 module
tester. This is a small Swing based application that allows you to test the ADF Business Components you
have 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.
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 the
JDeveloper menu bar to save your work.
LESSON 5 – CREATING MULTIPLE PAGE WEBSITES –
PAGE FLOWS
Summary:
Web applications usually have more than one page in them. In the next section you are going to add another
page 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 we'll create in a minute.
From the Component Palette choose a Control Flow Case and then click on the DeptEmpPage and drag a
line to the query page.




Name this line goQuery.




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




Double 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.
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 the
All 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.
In the Data Controls accordion select the EmpDetails1 data control and drag it into the center area of
the 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.
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 property
select back from the drop down list. This will cause the button to perform the navigation you defined in
the page flow.
Next we'll add transaction operations to the page to allow you to commit and rollback changes. In the
Data Controls Palette expand the application module level Operations node to locate the commit and
rollback operations. Drag the Commit operation into the structure pane before the First Button. When
prompted for a drop target choose ADF Button




Repeat the same steps for the Rollback operation.
In the Property Inspector, for the Rollback and for the Commit buttons, expand the Behavior section and
set the Disabled property to default.




If you'll maximize the design editor at this stage by double clicking the query.jspx tab, your page should
look like this:




Switch back to editing the DeptEmpPage.jspx by clicking on its tab or opening the file from the
Application Navigator.
A quick way to navigate to this or any other file is using the global find 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.




In the page design, expand the Departments accordion. From the Component Palette, choose a Button
component 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 and
choose 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 property
type goQuery or select it from the drop down list if available (NOTE: in some cases it will not be in the
pulldown menu). This will cause the button to perform the navigation you defined in the page flow.
Click the Save All icon on the JDeveloper menu bar to save your work, and then right click the
DeptEmpPage.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%.
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 and
updating data for employees. Note how this form displays a view of the data that matches the definition
in the view object you created - including information for Department name as well as a list of values for
the Job id.

You can also make changes to the data and commit and rollback your transaction as needed.
Close your browser window.
LESSON 6 – CREATING JEE5 STATELESS SESSION EJBS
Summary:
In this lab, a new project will be added to the HRSystem application which will encapsulate the business logic
required for checking the credit for the employees. This business logic will be implemented as a distributed
service using a JEE5 Stateless Session EJB. Stateless Session EJBs are often used in practice to encapsulate
business logic because they scale very well, are well known, and are supported by all main-stream application
servers 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”
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”
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”
In the next screen, you can see that the wizard gives the option of either creating a Remote Interface, a
Local Interface or both. We will create both so you can see the artifacts which are created, even though
this 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”
The CreditScoreApp Overview page will be displayed so you can see an overall view of the EJB

7. 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
   @Local

8. 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;
     }
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 icon




10. We are now done creating our Stateless Session EJB. Next we want to deploy this to WebLogic so we
    can test it.
First, we need to create a new deployment profile. A deployment profile tells JDeveloper how to
package 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.
Select “OK” again to dismiss the Project Properties dialog.
   Select the Save All – now we’re ready to deploy

11. 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:
Select “testdomain_wls11gserver” from the list of available WebLogic server instances. Make sure that
the “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 open
and 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”
Check that the deployment finished successfully in the “Deployment” tab in JDeveloper




12. 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/console

13. 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 WebLogic




14. 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…”
This will bring up a small dialog asking which project you would like to put the test client in, or if you’d
like 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 that
pulldown 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 method
called “getInitialContext()” which will lookup WebLogic’s JNDI tree context so the new EJB can be looked
up easily from the main method.

Modify the CreditScoreLocalClient.java so that it will cycle through several employee IDs and make sure
that the business logic within the Stateless Session EJB is working correctly. A suggestion is to add the
following 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.
Right-click on CreditScoreLocalClient.java and select Run




You should now see the output from the test client program which has successfully called the new
Stateless Session EJB with several different employee ID and returned different credit scores:
LESSON 7 – CREATING JAX-WS WEB SERVICES
Summary:
In this lesson, the Stateless EJB just created in the previous lab will be wrapped with a Web Service to show a
bottom-up Web Service design. We will also show top-down web-service development by providing a WSDL
which defines a new web service which will be created based on that WSDL as a base design that we will then
implement 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”
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:
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.
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”
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” button




Examine the Service Request and Service Response payloads shown in the getCreditScore Request Detail
section. Note that the return value is 400 just as it was with the Stateless Session EJB test client.
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 Service

Oracle JDeveloper support multiple ways of creating Web Services. JDeveloper wizards include the ability to
create Web Services from EJBs, POJOs (Plain Old Java Objects), Database DML and PL/SQL, JMS and others. In
this lab we’ll use what’s often described as a best practice: Top-Down development. Using this method we start
by using WSDL and let JDeveloper generate the Java Web Service from there. All we have to do from that point
is 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”
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”
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”
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':
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 – not
practical, but it acts as a stub for real business logic you could implement to read the salaries from the
HR 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 the
TotalSalaryService project, select Deploy -> WebServices… then select the testdomain_wls11gserver
application server as a deployment target.
After the web service has been deployed successfully, go to the WebLogic console and expand the
newly deployed application “TotalSalaryApp-TotalSalaryService-context-root” deployment, then select
the “TotalSalaryService” web service.




Once again, navigate to the “Testing” tab, expand the “TotalSalaryService” node, then select the “Test
client” link to launch the integration WebLogic web services test harness.
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 of
the test client window.
LESSON 8 – ADDING THE NEW SERVICES INTO THE
ADF APPLICATION
Summary:

In this lab, we will take the Stateless Session EJB and WebService created in the previous labs and incorporate
these 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”
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
Don’t select any authentication for the endpoint




Review 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’s view

2. 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.
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.
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             700

Step B: Exposing the TotalSalary Web Service

The 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
Name this Data Control “TotalSalaryDataControl”. Copy the WSDL URL from the WebLogic console in a
similar 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” button




Shuttle the TotalSalary operation from the “Available” to the “Selected” column, then select “Next”
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”
Review the configuration and select “Finish” to create the new Data Control for the TotalSalaryService

2. 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....
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.
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
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’t
been setup and these can be ignored.

<Error> <oracle.wsm.resources.policymanager> <WSM-02054> <Failure in looking up EJB component
PolicyAccessService#oracle.wsm.policymanager.ejb.IStringPolicyAccessServiceRemote.>

You have now completed integrating the new services into the HRSystem application as shown below:
LESSON 9 – DATA VALIDATION (OPTIONAL)
Summary:

This exercise will enhance the application that we have created. In this lab you refine your business services by
adding 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 configured

Activity 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.
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.
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 we'll add a default value to the hired date field - so when we create a new employee we'll have
   today's 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 today's date.
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 we'll 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.
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.
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)

More Related Content

What's hot

Oracle ebs r12_architecture
Oracle ebs r12_architectureOracle ebs r12_architecture
Oracle ebs r12_architectureprasanna432
 
Calendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementCalendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementFeras Ahmad
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Hr profile option
Hr profile optionHr profile option
Hr profile optionFeras Ahmad
 
Oracle Concurrent Program Setup document
Oracle Concurrent Program Setup  documentOracle Concurrent Program Setup  document
Oracle Concurrent Program Setup documentvenkatesh gurusamy
 
Check element entry value on particular effective date
Check element entry value on particular effective dateCheck element entry value on particular effective date
Check element entry value on particular effective dateFeras Ahmad
 
Oracle Applications R12 architecture
Oracle Applications R12 architectureOracle Applications R12 architecture
Oracle Applications R12 architectureSekhar Byna
 
Oracle Apps Technical – Short notes on RICE Components.
Oracle Apps Technical – Short notes on RICE Components.Oracle Apps Technical – Short notes on RICE Components.
Oracle Apps Technical – Short notes on RICE Components.Boopathy CS
 
Payroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMPayroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMFeras Ahmad
 
Customize the login homepage For Oracle EBS R12
Customize the login homepage For Oracle EBS R12Customize the login homepage For Oracle EBS R12
Customize the login homepage For Oracle EBS R12Ahmed Elshayeb
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Oracle EBS R12 Audit trial
Oracle EBS R12 Audit trialOracle EBS R12 Audit trial
Oracle EBS R12 Audit trialFeras Ahmad
 
Oracle HRMS Payroll Table Overview
Oracle HRMS Payroll Table OverviewOracle HRMS Payroll Table Overview
Oracle HRMS Payroll Table OverviewChris Martin
 
Web adi webcast_v3
Web adi webcast_v3Web adi webcast_v3
Web adi webcast_v3Bala Nagella
 
Accrual plan set up in oracle hrms
Accrual plan set up in oracle hrmsAccrual plan set up in oracle hrms
Accrual plan set up in oracle hrmsRajiv reddy
 

What's hot (20)

Oracle ebs r12_architecture
Oracle ebs r12_architectureOracle ebs r12_architecture
Oracle ebs r12_architecture
 
Calendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementCalendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence management
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Understanding Physical Inventory
Understanding Physical InventoryUnderstanding Physical Inventory
Understanding Physical Inventory
 
React hooks
React hooksReact hooks
React hooks
 
Hr profile option
Hr profile optionHr profile option
Hr profile option
 
Oracle Concurrent Program Setup document
Oracle Concurrent Program Setup  documentOracle Concurrent Program Setup  document
Oracle Concurrent Program Setup document
 
Oaf personalization examples
Oaf personalization examplesOaf personalization examples
Oaf personalization examples
 
Check element entry value on particular effective date
Check element entry value on particular effective dateCheck element entry value on particular effective date
Check element entry value on particular effective date
 
Oracle Applications R12 architecture
Oracle Applications R12 architectureOracle Applications R12 architecture
Oracle Applications R12 architecture
 
Serial Control Item in Oracle EBS
Serial Control Item in Oracle EBSSerial Control Item in Oracle EBS
Serial Control Item in Oracle EBS
 
Oracle Apps Technical – Short notes on RICE Components.
Oracle Apps Technical – Short notes on RICE Components.Oracle Apps Technical – Short notes on RICE Components.
Oracle Apps Technical – Short notes on RICE Components.
 
Payroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCMPayroll costing details Oracle Fusion Cloud HCM
Payroll costing details Oracle Fusion Cloud HCM
 
Customize the login homepage For Oracle EBS R12
Customize the login homepage For Oracle EBS R12Customize the login homepage For Oracle EBS R12
Customize the login homepage For Oracle EBS R12
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
Oracle EBS R12 Audit trial
Oracle EBS R12 Audit trialOracle EBS R12 Audit trial
Oracle EBS R12 Audit trial
 
Oracle HRMS Payroll Table Overview
Oracle HRMS Payroll Table OverviewOracle HRMS Payroll Table Overview
Oracle HRMS Payroll Table Overview
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
Web adi webcast_v3
Web adi webcast_v3Web adi webcast_v3
Web adi webcast_v3
 
Accrual plan set up in oracle hrms
Accrual plan set up in oracle hrmsAccrual plan set up in oracle hrms
Accrual plan set up in oracle hrms
 

Similar to Oracle ADF 11g Tutorial

Developing RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdfDeveloping RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdfsheriframadan18
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part IIMichael Fons
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialRakesh Gujjarlapudi
 
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I  GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I MatthewTennant613
 
OBIEE: How to change dashboard background color or add background image
OBIEE: How to change dashboard background color or add background imageOBIEE: How to change dashboard background color or add background image
OBIEE: How to change dashboard background color or add background imageMohamed Attia
 
Oracle application express ppt
Oracle application express pptOracle application express ppt
Oracle application express pptAbhinaw Kumar
 
Oracle application express
Oracle application expressOracle application express
Oracle application expressAbhinaw Kumar
 
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1Jsf On Rails Ejb Jpa Jsf Adf11g Demo1
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1Lucas Jellema
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web MahmoudOHassouna
 
Adapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureAdapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureprathap kumar
 
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-viewFaina Fridman
 

Similar to Oracle ADF 11g Tutorial (20)

Developing RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdfDeveloping RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdf
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
 
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I  GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
 
OBIEE: How to change dashboard background color or add background image
OBIEE: How to change dashboard background color or add background imageOBIEE: How to change dashboard background color or add background image
OBIEE: How to change dashboard background color or add background image
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
Homestead Weather workshop
Homestead Weather workshopHomestead Weather workshop
Homestead Weather workshop
 
Oracle OSB Tutorial 1
Oracle OSB Tutorial 1Oracle OSB Tutorial 1
Oracle OSB Tutorial 1
 
Oracle application express ppt
Oracle application express pptOracle application express ppt
Oracle application express ppt
 
Oracle application express
Oracle application expressOracle application express
Oracle application express
 
Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2
 
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1Jsf On Rails Ejb Jpa Jsf Adf11g Demo1
Jsf On Rails Ejb Jpa Jsf Adf11g Demo1
 
BI Step by Step
BI Step by StepBI Step by Step
BI Step by Step
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
Adapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureAdapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedure
 
Dbi h315
Dbi h315Dbi h315
Dbi h315
 
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
 
Sharepoint
SharepointSharepoint
Sharepoint
 
Sharepoint
SharepointSharepoint
Sharepoint
 
Sharepoint
SharepointSharepoint
Sharepoint
 

More from Rakesh Gujjarlapudi

Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesRakesh Gujjarlapudi
 
Oracle SOA, BPM, OSB, BAM, & B2B 12C
Oracle SOA, BPM, OSB, BAM, & B2B 12COracle SOA, BPM, OSB, BAM, & B2B 12C
Oracle SOA, BPM, OSB, BAM, & B2B 12CRakesh Gujjarlapudi
 
Lesson1 - SOA Governance Overview
Lesson1  - SOA Governance OverviewLesson1  - SOA Governance Overview
Lesson1 - SOA Governance OverviewRakesh Gujjarlapudi
 
Weblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationWeblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationRakesh Gujjarlapudi
 
Oracle fusionmiddlewarecontinuosintegration slideshare_v1
Oracle fusionmiddlewarecontinuosintegration slideshare_v1Oracle fusionmiddlewarecontinuosintegration slideshare_v1
Oracle fusionmiddlewarecontinuosintegration slideshare_v1Rakesh Gujjarlapudi
 
SOA OSB suite cluster installation
SOA OSB suite cluster installationSOA OSB suite cluster installation
SOA OSB suite cluster installationRakesh Gujjarlapudi
 
Enterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cEnterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cRakesh Gujjarlapudi
 
Oracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMOracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMRakesh Gujjarlapudi
 
Oracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSOracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSRakesh Gujjarlapudi
 

More from Rakesh Gujjarlapudi (18)

Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to Kubernetes
 
Oracle SOA, BPM, OSB, BAM, & B2B 12C
Oracle SOA, BPM, OSB, BAM, & B2B 12COracle SOA, BPM, OSB, BAM, & B2B 12C
Oracle SOA, BPM, OSB, BAM, & B2B 12C
 
Lesson1 - SOA Governance Overview
Lesson1  - SOA Governance OverviewLesson1  - SOA Governance Overview
Lesson1 - SOA Governance Overview
 
Oracle API Gateway Installation
Oracle API Gateway InstallationOracle API Gateway Installation
Oracle API Gateway Installation
 
Oracle API Gateway
Oracle API GatewayOracle API Gateway
Oracle API Gateway
 
Weblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationWeblogic Administration Managed Server migration
Weblogic Administration Managed Server migration
 
Oracle fusionmiddlewarecontinuosintegration slideshare_v1
Oracle fusionmiddlewarecontinuosintegration slideshare_v1Oracle fusionmiddlewarecontinuosintegration slideshare_v1
Oracle fusionmiddlewarecontinuosintegration slideshare_v1
 
SOA OSB suite cluster installation
SOA OSB suite cluster installationSOA OSB suite cluster installation
SOA OSB suite cluster installation
 
Enterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cEnterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12c
 
Oracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMOracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSM
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
 
Oracle OSB Tutorial 2
Oracle OSB Tutorial 2Oracle OSB Tutorial 2
Oracle OSB Tutorial 2
 
Oracle WebLogic 11g Topology
Oracle WebLogic 11g TopologyOracle WebLogic 11g Topology
Oracle WebLogic 11g Topology
 
Oracle EMC 12C Grand Tour
Oracle EMC 12C Grand TourOracle EMC 12C Grand Tour
Oracle EMC 12C Grand Tour
 
Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1
 
Oracle EMC 12 Installation
Oracle EMC 12 InstallationOracle EMC 12 Installation
Oracle EMC 12 Installation
 
Oracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSOracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPS
 
Oracle Web Logic server
Oracle Web Logic serverOracle Web Logic server
Oracle Web Logic server
 

Oracle ADF 11g Tutorial

  • 1. Oracle ADF 11g Developer Lesson Name – Rakesh Gujjarlapudi Email Address – rakesh_gujj@yahoo.com
  • 2. OVERVIEW  Installing Oracle Express 10g Database  Installing Oracle WebLogic Server 11g & JDeveloper 11g  Creating a WebLogic Server 11g Domain WebLogic Server 11g Info: MIDDLEWARE_HOME=/home/oracle/Oracle/JDev11113 Configuration Wizard = ${MIDDLEWARE_HOME}/wlserver_10.3/common/bin/config.sh Domain Home: /home/oracle/Oracle/JDev11113/user_projects/domains/testdomain Admin Server Console: http://localhost:7001/console User: “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/jdev Lab Project Location = /home/oracle/jdeveloper/mywork/HRSystem Oracle XE Info: Database Version: 10.2.0 (10g) Starting Oracle XE: /etc/init.d/oracle-xe start Stopping Oracle XE: /etc/init.d/oracle-xe stop User: sys / welcome1 User: HR / welcome1 JDK Info: JDK1.6.0_22 – installed at: /usr/local/bin/jdk1.6.0_22
  • 3. LESSON 1 – CREATING AN ADF APPLICATION Summary: This exercise will walk you through the steps of creating a rich internet application using Application Development Framework (ADF) using JDeveloper. The purpose of this lab is to get you some familiarity with JDeveloper and ADF. In this lab, we will create an ADF application that connects to a backend database and retrieves information abbot departments and employees in that department. Additionally, the ADF application will 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.html Activity Steps: Step A: Creating a New ADF Application and Business Components When you work in JDeveloper, you organize your work in projects within an application. JDeveloper provides several templates that you can use to create an Application and projects. The templates are pre-configured with a basic set of technologies that are needed for developing various types of applications, and you create your working environment by selecting the template that fits your needs. You can then configure it to add any other technologies you plan to use. In the first section you are going to create a new Application using the Fusion technology 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. 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. 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 Finish In the CheckList pane, click the Connect to a Database step The step expands showing useful information such as prerequisites required for performing this task. Click the Create a Database Connection button.
  • 5. Specify the following properties for the new connection you are creating: Connection Name: HRConn Username: HR Password: welcome1 SID: XE Click the Test Connection button on the Create Database Connection dialog to verify that a successful connection Once done, click the OK button to exit out of the Create Database Connection dialog Click the down arrow to collapse the Connect to a Database step In the Checklist pane, set the status of the Connect to a Database step to Done
  • 6. Click the Build Business Services step to expand it, then click the Go to Substeps button In the subtask list, click the Create Entity Objects and Associations subtask Click the Create Entity Objects and Associations button In the Select Project for Action dialog, select the Model project
  • 7. In the Initialize Business Components Project dialog, verify that the HRConn connection is already selected Click OK in the Initialize Business Components Project dialog In the Entity Objects page, click the Query button to examine the data dictionary and see available tables Select the DEPARTMENTS and EMPLOYEES tables in the Available list, and click the right arrow to move your selections to the selected list.
  • 8. NOTE: This step creates updateable Entity Objects based on the tables you chose. Click Next to continue In the Updateable View Objects dialog, move Departments (DEPARTMENTS) and Employees (EMPLOYEES) to the selected list NOTE: This step creates matching view objects DepartmentsView and EmployeesView to perform queries on the entity object you created before. Click Next to continue In the Read Only View Objects dialog, click the Query button and then move JOBS to the Selected list NOTE: This step creates a read only view object that queries the Jobs table Click Next to continue In the Application Module dialog, click Finish to create the business components in the Model project
  • 9. In the Subtask list, click on the Close Step 3 button Set the status of the Build Business Services step to Done Step B: Creating JSF Web pages Having completed the creation of the business components (Model and View objects), we can now build the user interface using JavaServer Faces (JSF), which is a standard Java EE technology that simplifies Web development. 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. You'll also use a master-detail relationship to display the information about employees in each department. To build the page you'll be using the Oracle ADF Faces Rich Client Components - these components allow you to build Ajax-based rich Web UI without writing low level HTML and Javascript code. The Web part of the application is developed in a separate
  • 10. project called the viewcontroller project. This separation between the Model layer and the user interface makes the business services more reusable. 2. We'll 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. 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, we'll delete the third one. Place your cursor in the right-most section called end and right click to choose Delete 6. In the Structure pane, with the af:pageTemplate selected, in the Property Inspector set the startColumnSize value to 350 to enlarge it 7. 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 page 8. Click the ShowDetails1 accordion that was created on the page, and in the Property Inspector change its Text property to Departments
  • 12. 9. From the Layout components, click-and-drag a Panel Splitter component onto the Center area of your page 10. In the Property Inspector change the Orientation property of the new splitter to be Vertical 11. 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. 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 page 13. 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 Employee 14. Your page should look like the image below 15. Click the Save All icon on the JDeveloper menu bar to save your work
  • 14. Step C: Binding Data Controls to your JSF page In the next few steps you are going to bind the business components you created to your user interface. You'll do this with simple drag and drop operations - behind the scene the ADF Model layer takes care of this binding for 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. 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 Form 4. 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. 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 you'll 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 Table 7. In the Edit Table Columns dialog, check the three check boxes for Row Selection, Sorting, and Filtering, and click OK
  • 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 Form 9. 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. 10. Your JSP should look like the image below 11. Click the Save All icon on the JDeveloper menu bar to save your work At this point, you have completed building the ADF application with master-detail relationship views. In the next lab we will establish a connection to a pre-installed local WebLogic Server and deploy and run this ADF application.
  • 19. LESSON 2 - DEPLOYING & RUNNING ADF APPLICATION ON WEBLOGIC SERVER Summary: This exercise will walk you through the steps of establishing a server connection to the local WebLogic Server we will deploy the application to, modifying the application and project properties so that the ADF application created in Lab 1 can be run on the WebLogic Server from JDeveloper. Activity Steps: Step A: Establishing a connection to WebLogic Server from JDeveloper We will establish a connection to WebLogic Server in JDeveloper so that you can stop and start WebLogic Server from JDeveloper. Note that once a connection is created to WebLogic Server, you can deploy any JEE application to 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. 4. On the Name and Domain screen of the New Application Server wizard, enter the following: a. Name: testdomain_wls11gserver
  • 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. 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 Select e. Once all the fields have been configured as shown below, Click Next
  • 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: testdomain 7. 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. 8. On the Finish screen of the New Application Server Wizard, click Finish
  • 25. 9. Once you click Finish in the previous step, the new application server configuration (testdomain_wls11gserver) should appear in your Application Server Navigator screen At this point you have configured a connection to the testdomain WebLogic domain and the WebLogic Server instance in the testdomain.
  • 26. Step B: Modifying ADF Application & Project Properties to use testdomain_wls11gserver In the next few steps we are going to modify the properties of the ADF Application so that we can deploy the ADF 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 connection information 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. 5. In the AppModule panel, select Configurations 6. In the Configurations panel, select the AppModuleLocal configuration and click on the edit icon ( )
  • 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 work Step C: Running the ADF Application Now that we have created the ADF application (in Lab 1) and configured the application and project to work with 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. 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. 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 field 5. 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. 6. Click a column heading in the table and drag it to reposition the column in the table 7. 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 B 8. 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 grid At this point we have completed the creation of a database-driven JEE application with a rich, AJAX-enabled user 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 developing applications using JDeveloper and WebLogic.
  • 32. LESSON 3 – ADF DATA VISUALIZATION COMPONENTS Summary: In this lab you are going to enhance your JSF page by changing the table of employees on our page to add the ability to do column selection and bind the business components to a graph representation to the user interface. You'll do this with simple drag and drop operations - behind the scene the ADF Model layer takes care of 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 the ability to do column selection and bind the business components to a graph representation to the user interface. You'll do this with simple drag and drop operations - behind the scene the ADF Model layer takes care of 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 we'll 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. The graph component is one of the ADF Faces Data Visualization components. The Graph can be displayed as static PNG image or an interactive Flash component. You can control these behaviours through the properties of the graph component. If there isn’t a Flash plug-in in the target browsers, for example, 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 graph type. 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. Then click the OK button. Select the dvt:pieGraph from the structure pane In 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 the target client machines. We are not going to change this in the lab because we have the FlashPlayer installed 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. Browse to department 30. Because you set the column selection to single, note the additional behaviors for 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 it displays when you hover over it with your mouse.
  • 36. When done, close the browser and return to JDeveloper. You are now completed with Lab 3: ADF Data Visualization Components
  • 37. LESSON 4 – CREATING MORE COMPLEX BUSINESS COMPONENTS Summary: In this section we'll add a new, more complex, Business Service to our application that will display a subset of the fields from the Employees table, along with the department name from the Departments table. We'll also add 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 declarative way. 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. Note that only the Employees entity has the updateable checkbox checked - the Departments entity is used to read data only. Click Next. In the Attributes dialog shuttle the following Employees attributes to the right: • EmployeeId • FirstName • LastName • Salary • HireDate • JobId And from the Departments entity shuttle the following attributes to the right: • DepartmentID • DepartmentName At 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 - we'll add an attribute that will show the yearly salary.
  • 39. In the EmpDetails.xml editor switch to the Attributes section and click the Add button to add a new attribute. In the New View Object Attribute dialog update the following fields: Field Value Name YearlySalary Type Number Value Type Expression Value Salary * 12 Click the OK button. In the next couple of steps we'll show how to add a list of values to a field based on a set of values stored in another table. In this case we'll 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 new view accessor.
  • 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 Of Values section click the Add button.
  • 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 the Default 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 user interface developers. In the Application Navigator double click the AppModule to open it for editing and choose the Data Model section of the editor.
  • 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 module tester. This is a small Swing based application that allows you to test the ADF Business Components you have 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. 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 the JDeveloper menu bar to save your work.
  • 44. LESSON 5 – CREATING MULTIPLE PAGE WEBSITES – PAGE FLOWS Summary: Web applications usually have more than one page in them. In the next section you are going to add another page 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 we'll create in a minute.
  • 45. From the Component Palette choose a Control Flow Case and then click on the DeptEmpPage and drag a line to the query page. Name this line goQuery. From the Component Palette choose another Control Flow Case and then create an opposite flow from the query page to the DeptEmpPage. Name this flow back Double 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. 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 the All 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. In the Data Controls accordion select the EmpDetails1 data control and drag it into the center area of the 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. 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 property select back from the drop down list. This will cause the button to perform the navigation you defined in the page flow.
  • 49. Next we'll add transaction operations to the page to allow you to commit and rollback changes. In the Data Controls Palette expand the application module level Operations node to locate the commit and rollback operations. Drag the Commit operation into the structure pane before the First Button. When prompted for a drop target choose ADF Button Repeat the same steps for the Rollback operation.
  • 50. In the Property Inspector, for the Rollback and for the Commit buttons, expand the Behavior section and set the Disabled property to default. If you'll maximize the design editor at this stage by double clicking the query.jspx tab, your page should look like this: Switch back to editing the DeptEmpPage.jspx by clicking on its tab or opening the file from the Application Navigator. A quick way to navigate to this or any other file is using the global find box at the top right of JDeveloper and typing the file name there,
  • 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 Button component 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 and choose 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 property type goQuery or select it from the drop down list if available (NOTE: in some cases it will not be in the pulldown menu). This will cause the button to perform the navigation you defined in the page flow.
  • 52. Click the Save All icon on the JDeveloper menu bar to save your work, and then right click the DeptEmpPage.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. 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 and updating data for employees. Note how this form displays a view of the data that matches the definition in the view object you created - including information for Department name as well as a list of values for the Job id. You can also make changes to the data and commit and rollback your transaction as needed.
  • 55. LESSON 6 – CREATING JEE5 STATELESS SESSION EJBS Summary: In this lab, a new project will be added to the HRSystem application which will encapsulate the business logic required for checking the credit for the employees. This business logic will be implemented as a distributed service using a JEE5 Stateless Session EJB. Stateless Session EJBs are often used in practice to encapsulate business logic because they scale very well, are well known, and are supported by all main-stream application servers 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. 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. 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. In the next screen, you can see that the wizard gives the option of either creating a Remote Interface, a Local Interface or both. We will create both so you can see the artifacts which are created, even though this 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. The CreditScoreApp Overview page will be displayed so you can see an overall view of the EJB 7. 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 @Local 8. 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. 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 icon 10. We are now done creating our Stateless Session EJB. Next we want to deploy this to WebLogic so we can test it.
  • 61. First, we need to create a new deployment profile. A deployment profile tells JDeveloper how to package 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. Select “OK” again to dismiss the Project Properties dialog. Select the Save All – now we’re ready to deploy 11. 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. Select “testdomain_wls11gserver” from the list of available WebLogic server instances. Make sure that the “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 open and 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. Check that the deployment finished successfully in the “Deployment” tab in JDeveloper 12. 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/console 13. 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 WebLogic 14. 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. This will bring up a small dialog asking which project you would like to put the test client in, or if you’d like 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 that pulldown 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 method called “getInitialContext()” which will lookup WebLogic’s JNDI tree context so the new EJB can be looked up easily from the main method. Modify the CreditScoreLocalClient.java so that it will cycle through several employee IDs and make sure that the business logic within the Stateless Session EJB is working correctly. A suggestion is to add the following 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. Right-click on CreditScoreLocalClient.java and select Run You should now see the output from the test client program which has successfully called the new Stateless Session EJB with several different employee ID and returned different credit scores:
  • 67. LESSON 7 – CREATING JAX-WS WEB SERVICES Summary: In this lesson, the Stateless EJB just created in the previous lab will be wrapped with a Web Service to show a bottom-up Web Service design. We will also show top-down web-service development by providing a WSDL which defines a new web service which will be created based on that WSDL as a base design that we will then implement 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. 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. 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. 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. 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” button Examine the Service Request and Service Response payloads shown in the getCreditScore Request Detail section. Note that the return value is 400 just as it was with the Stateless Session EJB test client.
  • 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 Service Oracle JDeveloper support multiple ways of creating Web Services. JDeveloper wizards include the ability to create Web Services from EJBs, POJOs (Plain Old Java Objects), Database DML and PL/SQL, JMS and others. In this lab we’ll use what’s often described as a best practice: Top-Down development. Using this method we start by using WSDL and let JDeveloper generate the Java Web Service from there. All we have to do from that point is 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. 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. 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. 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. 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 – not practical, but it acts as a stub for real business logic you could implement to read the salaries from the HR 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 the TotalSalaryService project, select Deploy -> WebServices… then select the testdomain_wls11gserver application server as a deployment target. After the web service has been deployed successfully, go to the WebLogic console and expand the newly deployed application “TotalSalaryApp-TotalSalaryService-context-root” deployment, then select the “TotalSalaryService” web service. Once again, navigate to the “Testing” tab, expand the “TotalSalaryService” node, then select the “Test client” link to launch the integration WebLogic web services test harness.
  • 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 of the test client window.
  • 78. LESSON 8 – ADDING THE NEW SERVICES INTO THE ADF APPLICATION Summary: In this lab, we will take the Stateless Session EJB and WebService created in the previous labs and incorporate these 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. 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. Don’t select any authentication for the endpoint Review the settings for the data control, then select Finish
  • 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 view 2. 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. 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. 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 700 Step B: Exposing the TotalSalary Web Service The 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. Name this Data Control “TotalSalaryDataControl”. Copy the WSDL URL from the WebLogic console in a similar 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” button Shuttle the TotalSalary operation from the “Available” to the “Selected” column, then select “Next”
  • 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. Review the configuration and select “Finish” to create the new Data Control for the TotalSalaryService 2. 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. 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. 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. 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’t been setup and these can be ignored. <Error> <oracle.wsm.resources.policymanager> <WSM-02054> <Failure in looking up EJB component PolicyAccessService#oracle.wsm.policymanager.ejb.IStringPolicyAccessServiceRemote.> You have now completed integrating the new services into the HRSystem application as shown below:
  • 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 by adding 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 configured Activity 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. 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. 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 we'll add a default value to the hired date field - so when we create a new employee we'll have today's 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 today's date.
  • 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 we'll 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. 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. 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)