Wednesday, June 23, 2010

How to Extend View Object in OAF?

1. Identify the VO to be extended.

This is the first thing that you have to determine.
Suppose you want to add address field to the following page:


Then you will go to "About this Page" link and find out the VO associated to this region.
In our case we will extend EmloyeeFullVO.



2. Create new workspace and new project.
Now go to JDeveloper and create new workspace and a new project.
Add the server.xml of the package where the VO to be extended is present to your . This will add complete package in your new project.
Add any other dependent packages if required.


3. In the new project create a new Business Component with default package as xxx.oracle.apps..... xxx being your identifier.
In our case we have taken xxx as xtendEmp.

4. Import the Business Component in which the VO to be extended is present. And import any other dependent component if required.

5. Create a new VO in the newly created package extending the VO to be extended.
Create a new VO with the additional address description field along with all the existing fields in the base VO.
This new VO should extend the base VO.



6. Click on .jpx and add the substitution.
In our case click on newEmp.jpx and add the substitution.


7. Upload the .jpx to the DB

Ex. java oracle.jrad.tools.xml.importer.JPXImporter TestXtend.jpx -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RWS60040REMS.US.ORACLE.COM)(PORT=1548))(CONNECT_DATA=(SID=HG0DV102)))"

While running the above command make sure that oracle.jrad.tools.xml.importer.JPXImporter is present in classpath.

8. Upload the .java and .xml files to the instance.
Either upload the .java and .xml files to the instance directly or create a jar file and add the jar file as first element in the classpath.
In our case we have created a jar file and placed in the classpath.

9. Bounce the Apache server.

10
. Create a new item on the page through personalization and attach the new field added it.
Now go back the screen where we wanted to add Address Description field.
Click on personaliza the link. And click on create item icon under the desired region.
Create the new Address item. Provide all properties:
ID -- Address
Data Type -- Varchar2
Prompt -- Address Description
CSS Style -- OraDataText
View Attribute -- Description (Be careful its case sensitive. Its should exactly same as you created in new VO)
View Instance -- EmployeeFullVO1 (VO instance name of base VO)




Thanks,
Agry

Tuesday, June 22, 2010

How to create Workflow based navigation for Oracle self service Pages?

Steps:

Workflow Builder Related Changes
1.
Create a work flow with a process like below.
You can see three functions. Each denotes a page.

Note: Each function should have an attribute with internal name OAPAGE and value similar to "page=/oracle/apps/ak/employee/webui/EmployeePG".
Invoking OANavigation.getNextPage will return this page.

Example:


OAF Related Changes


2. When user opens the Update link,(as shown in above image) we start the workflow and navigate the user to the next page using the following code.
---------------------------------------------------------
    String nextPage = null;
    String wfkey = null;
    String address_Id = pageContext.getParameter("addressId");
    String address_Name = pageContext.getParameter("addressName");
    HashMap params = new HashMap();
    params.put("addressId",address_Id);
    params.put("addressName",address_Name);

    if ("update".equals(pageContext.getParameter(EVENT_PARAM))) // check if update event is fired
      {
        if(!OANavigation.isWorkflowInProgress(pageContext))
// starting a new workflow only if there is no wf associated with existing pageContext.
        {
          wfkey = am.invokeMethod("getNewWFId").toString();
          OANavigation.createProcess(pageContext,"MANADDUP","UPDATE",wfkey); 
//creating new workflow process
          OANavigation.startProcess(pageContext,"MANADDUP","UPDATE",wfkey);
        }
        nextPage = OANavigation.getNextPage(pageContext,"MANADDUP",wfkey,"UPDATE",false);
// this will give the value of next page which we have added in function attributes

        pageContext.setForwardURL(pageContext.getApplicationJSP()+"?"+nextPage,
            null,        
            OAWebBeanConstants.KEEP_MENU_CONTEXT,
            null,           
            params,           
            true,          // Retain AM        
            OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
            // Do not display breadcrumbs                          
            OAException.ERROR);
    }


---------------------------------------------------------

The above code goes in the CO of the page which holds the Update button.

3.  In the CO of subsequent pages we can get the next page by providing the result of the current function.

---------------------------------------------------------
if ("next".equals(pageContext.getParameter(EVENT_PARAM)))
      {  

        nextPage = OANavigation.getNextPage(pageContext,"NEXT");
// we are passing result as NEXT.

        pageContext.setForwardURL(pageContext.getApplicationJSP()+"?"+nextPage,
            null,          
            OAWebBeanConstants.KEEP_MENU_CONTEXT,  
            null,             
            null,             
            true,          // Retain AM          
            OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
            // Do not display breadcrumbs                            
            OAException.ERROR);
    }

---------------------------------------------------------
Similarly if you pass result as PREVIOUS then you will get value of nextPage as the previous page.

4. In the CO of last page use the same code to move the WF ahead but do not use the value of nextpage as it will be null.
---------------------------------------------------------
        nextPage = OANavigation.getNextPage(pageContext,"SUBMIT"); // this will end the WF. Value of nextPage will be null.
---------------------------------------------------------

Thanks,
Agry