Anil's Blog is Best Viewed on GOOGLE CHROME

Sunday, May 10, 2009

Overview of the OA-Framework Components


OA-Framework is a very rich and powerfull development tool ; we will not start an in-depth discussion about how it works, but here is the main vocabulary you will need :


MDS - The declarative metadata repository used with 11.5.10+ OA Framework applications. This replaced the older AK Repository.

Page
The first component is the page ; a page is a set of regions (header, footer, table…), and each region can contain items (field, button, checkbox...), or other regions.


Pages are XML files found under $APPL_TOP/MDS folder example:-

$appl_top/pa/11.5.0/mds/project/webui/MyProjectsPG.xml

BC4J : Business Components for Java
BC4J is a set of java libraries that meshes SQL database concepts like views, tables and transactions into the Java world via View Objects (VOs), Entity Objects (EOs), and Application Modules (AMs).

All BC4J components are found under $JAVA_TOP example:-

Application Module, View Object, View Link, PVO found under:-
$JAVA_TOP/oracle/apps/pa/project/server/

Controller found under:- $JAVA_TOP/oracle/apps/pa/project/webui/

Entity Object, Validation View Object, Validation Application Module found under:-
$JAVA_TOP/oracle/apps/pa/project/scheme/server/


View Object
In the simplest terms, a BC4J view object encapsulates a database query and provides iteration over and access to the view rows in its result set.

Entity Object
When we handle data through a page - INSERT / UPDATE / DELETE - we do this by using an Entity Object. An Entity Object is a java representation of a table ; each column of the table is mapped to an "Entity Attribute".


Application Module
An application module is a container for related BC4J objects. The AM is connected to the database, and is responsible for the commit and rollback of a transaction.


Controller
The controller is the java code in charge of loading a page when we call it. It is also in charge of handling an event on a page, like a click on a button, or the call of a List Of Values. It has three Methods:-


1. ProcessRequest
2. ProcessFormData
3. ProcessFormRequest






Find the right JDeveloper Patch for OAF development

To determine which patch to use, you can simply check the framework version in your instance by using http://host:port/OA_HTML/OAInfo.jsp, then choose the matched one.

11.5.10K = patch 4045639
11.5.101CU = patch 4141787
11.5.102CU = patch 4573517
11.5.103CU = patch 4725670

It would be interesting to have a survey regarding what framework versions are being used for OAF development. Please post your current development version in a comment; I will publish the results at a later stage.
Checkout Metalink note 416708.1 for the up to date list of OAF releases.


Saturday, May 2, 2009

How do I find rows that were selected by the table selector

Application Module Code


import oracle.jbo.RowSetIterator;

public void checkSelectedrow()
{

OAViewObject vo = getTeamRoleListVO1();
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator selectIter = vo.createRowSetIterator("selectIter");

if (fetchedRowCount > 0)
{
// Save the original range size and range start.
 selectIter.setRangeStart(0);
 selectIter.setRangeSize(fetchedRowCount);

//Creates a Transient Attribute of "String" type.





for (int i = 0; i < fetchedRowCount; i++)
{
TeamRoleListVORowImpl rowi = (TeamRoleListVORowImpl)selectIter.getRowAtRangeIndex(i);
String selectFlag = rowi.getSelectFlag()+""; 

if("Y".equals(selectFlag )
{
 //  Getting selected row.
}
}
}
 selectIter.closeRowSetIterator(); }

Retaining issue in LOV whenever any Event occurs

Issue


You have a messageLovInput and you also return the value in some column like messageStyledTextbut as soon as any event fires on page the value in the messageStyledText wipeout.


How to Overcome this issue


Instead of creating item of messageStyledText create item of type messageTextInput and set it read only property to "TRUE".

This will certainly solve the issue.

Insert a new record by createRow()



In Application Module Impl

Row row = vo.createRow();
row.setAttribute("MemFirstname","Anil");
row.setAttribute("MemLastname","Sharma");
vo.insertRow(row);
getTransaction().commit();

How-to persist and retrieve user defined SQL objects using JDBC

http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/objects/ObjectTypes.html

How to return an array from a PL/SQL Stored function

http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/varray/index.html

Sequence in EO

First Cross check that Create Method is clicked in EO.

Then go to EOImpl

public void create(AttributeList attributeList)
{
super.create(attributeList);
setPersonId(getOADBTransaction().getSequenceValue("PER_PEOPLE_S"));
}

Good Java Basic Examples

http://www.java-examples.com/java-string-startswith-example

Partial Page Rendering (PPR)

A mechanism for selectively refreshing parts of a page (as opposed to the whole page) in response to user actions. For example, if a user sorts a table, only the table's contents changes; the rest of the page remains the same.

The FND: Disable Partial Page Rendering profile option must be set to No. If this profile value is set to Yes, a Go button renders next to each item you configure to raise a PPR event).

Important :-
Note: UIX currently does not support the ability to hide components whose direct parent region is a cellFormat or a rowLayout. As a workaround, to hide a component such as a button in a cellFormat, add flowLayout to your cellFormat region first, then add the button to the flowLayout

SPEL syntax : ${oa.ViewInstanceName.viewAttributeName>}
Example  ${oa.EmployeePVO1.EmpManagerRender}

You need to set this syntax on the attribute on which you want to enable PPR in the Parameters window. At runtime, this item will render according to the value of the EmpManagerRender attribute in the EmployeePVO1 view object.

To enable PPR on page, you must create an OA Framework standard applications properties view object (PVO) including a transient attribute for tracking the state of the visible property for the Attribute.

The application properties view object should be created in the same package as your module's other UI BC4J components. Note that you should have only one application properties view object per application module (it can include attributes used by different pages that share the same root UI application module).


Warning: This lesson assumes that you have completed the Create Exercise from Tutorial - shipped in Jdev Itself, and builds on that work. If you have not completed this exercise, please do so before proceeding

In this exercise we will implement the Partial Page Rendering.  Depending upon the value in Position Poplist will change the "Render Property" of Manager.

If the Position poplist value is null or PRESIDENT, the Manager field does not display. If it is set to any other value, the Manager field displays and is required.


Steps:

1. Create an "Application Properties" View Object
2. Add the EmployeePVO View Object to the EmployeeAM
3. Configure the Position Item to Fire a PPR Action When Changed
4. Configure the MgrName Item to React to PPR Events
5. Implement PPR Event Handling in Controller and Application Module Impl

Step1:
Create the EmployeePVO View Object

In the oracle.apps.ak.employee.server package, create the EmployeePVO view object.
In the Attributes page, select the New... button and create a transient primary key attribute with the following properties:
         * Name: RowKey
         * Type: Number
         * Updateable: Always
         * Key Attribute (checked)

Select the New... button again and create a transient attribute with the following properties:

        * Name: EmpManagerRender
        * Type: Boolean
        * Updateable: Always

You do not need to generate any Java files for this PVO.

After you create the PVO, reopen and navigate to the Tuning page. Check the Enable Passivation and For All Transient Attributes checkboxes (it's important that the transient attributes in an application properties view object be properly passivated).


Step2:
Add the EmployeePVO view object to the EmployeeAM.[Create the EmployeeAM if not created yet.]

Step3:
Configure the Position Item to Fire a PPR Action when changed. Set the following properties for the Position item in your page:

Property                                                                    Value

Disable Server Side Validation                                    True
Disable Client Side Validation                                     True
Action Type                                                               firePartialAction
Event                                                                    empPositionChange
Submit                                                                       True

Step 4
Configure the MgrName Item to React to PPR Events


Set the value of the Rendered property to the following SPEL ("Simplest Possible Expression Language") syntax indicating that the property value should be obtained from the EmployeePVO1 instance's EmpManagerRender attribute:

${oa.EmployeePVO1.EmpManagerRender}

Step 5
Implement PPR Event Handling

Controller Code

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
      // Always call this first.
      super.processRequest(pageContext, webBean);
      // Iniitalize the ApplicationPropertiesVO for PPR.
      am.invokeMethod("init");
}

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    // Always call this first.
    super.processFormRequest(pageContext, webBean);

if ("empPositionChange".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    {
      // The Position poplist PPR change event has fired.
      am.invokeMethod("handlePositionChangeEvent");
    }
   }

Application Module Code

public void init()
{
OAViewObject appPropsVO = (OAViewObject)findViewObject("EmployeePVO1");
if (appPropsVO != null)
{
   if (appPropsVO.getFetchedRowCount() == 0)
   {
     appPropsVO.setMaxFetchSize(0);
     appPropsVO.executeQuery();
     appPropsVO.insertRow(appPropsVO.createRow());
// Set the primary key value for this single-rwo VO.
   OARow row = (OARow)appPropsVO.first();
   row.setAttribute("RowKey", new Number(1));
   }
}
 handlePositionChangeEvent();
}

public void handlePositionChangeEvent()
{
// Get the special, single-row application properties and make the first (only) row current.

OAViewObject vo = (OAViewObject)findViewObject("EmployeePVO1");
OARow row = (OARow)vo.first();

// Get the value of the view object attribute with the position code.

OAViewObject empVO = (OAViewObject)findViewObject("EmployeeFullVO1");
OARow empRow = (OARow)empVO.getCurrentRow();

String position = (String)empRow.getAttribute("PositionCode");
  if ((position == null) || ("PRESIDENT".equals(position)))
  {
  row.setAttribute("EmpManagerRender", Boolean.FALSE);
  }
else
   row.setAttribute("EmpManagerRender", Boolean.TRUE);
  }
}
Read Chapter Dynamic User Interface in Dev Guide for more details.....

Profile Option to get HOST & PORT

Profile option "CSF: eLocation Map host name" to get the host name of Oracle Database.
Profile option "CSF: Database port to receive data" to get the port number.

Comparision of Dates in Controller

OAViewObject oaviewobject1 = (OAViewObject)am.findViewObject("NewEmployeeVO1");

System.out.println("1");
if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();


Date sDate =(Date)row.getAttribute("EffectiveStartDate");

Date eDate =(Date)row.getAttribute("EffectiveEndDate");
java.util.Date VChangeDateTime =
new java.util.Date(sDate.timestampValue().getTime());

if (sDate !=null && eDate !=null)
{
long m1 = sDate.timestampValue().getTime() ;
long m2 = eDate.timestampValue().getTime();

long diff = m2 - m1;

int diffDays = Math.round(diff / (24 * 60 * 60 * 1000));

if (diffDays >365)
{
System.out.println("Date is greater than 365");
}
else

{
System.out.println("Date is less than 365");
}

To Find out the event Occur

Controller Code:

String event = pageContext.getParameter(EVENT_PARAM);

Table Events

The various table events are:
1. Navigation - user selects the Next or Previous link to navigate between different ranges of rows.
2. Sorting - user selects a beveled column heading to sort that column in ascending or descending order.
3. Insertion of a new row - user selects the Add Another Row button.
4. Recalculate column Total - user selects the Recalculate button to update the column total.
5. Detail Disclosure - user selects the Hide or Show link to collapse or expand the detail disclosure region.
6. Table Control - user selects the Action/Navigation button in the table Control bar.

You may wish to familiarize yourself with the set of UIX "hidden" fields so you can capture these events and implement custom behavior on them. The "hidden" fields are UIX attributes in the UIConstants interface.

These parameters are set only when a form submit event is induced from a table. They are:
1. SOURCE_PARAM - indicates the source of the event that is generating the current browser request.
This maps to the name attribute of the web bean. If you wish to check whether a table generated an event, you include in your code:

if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)))
{
...
}

2. EVENT_PARAM - indicates the event generated by a web bean (a table, in this case). The possible events generated by a table are:

3. GOTO_EVENT - when 'Next' or 'Previous' navigation links are selected

4. SORT_EVENT - when a column header is selected to sort that column

5. HIDE_EVENT - when the 'Hide' link of a detail disclosure is selected

6. SHOW_EVENT - when the 'Show' link of a detail disclosure is selected

7. ADD_ROWS_EVENT - when the 'Add Another Row' button is selected

8. UPDATE_EVENT - when the total row 'Recalculate' button is selected

9. VALUE_PARAM - indicates a value that is relevant to a particular event:

10.When a detail disclosure Hide/Show is selected, the value parameter contains the row index
corresponding to the row whose Hide/Show was selected.

11. When the 'Next' or 'Previous' link of table navigation bar is selected, the value parameter contains the index of the first row of the current range. For example, when the row range 1-10 is displayed, the value is 1 and when the row range 11-20 is displayed, the value is 11.

12. SIZE_PARAM - indicates the number of rows currently displayed in the table (relevant only to the navigation event).

13. STATE_PARAM - indicates the current sort state (ascending or descending) of the column on which sorting is invoked (relevant only for the sort event). Example Usage

To check for the "Add Rows" event:

if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)))
&& ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))
{
...
}

raiseDeveloperException - To see output OnScreen

pageContext.raiseDeveloperException(new OAException ("Test VALUE IS "+ pageContext.getParameter("fruitRadioGroup")));

Thursday, April 30, 2009

RADIO GROUP EVENT

import oracle.apps.fnd.framework.webui.beans.message.OAMessageRadioButtonBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageRadioGroupBean;

//If you want your radio buttons to behave as a group, you must programmatically assign them all the same name by calling setName() for each radio button.

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);


OAMessageRadioButtonBean appleButton =
(OAMessageRadioButtonBean)webBean.findChildRecursive("GroupButtonOne"); //First Radio Button
appleButton.setName("fruitRadioGroup");
appleButton.setValue("APPLES");

OAMessageRadioButtonBean orangeButton =
(OAMessageRadioButtonBean)webBean.findChildRecursive("GroupButtonTwo"); //Second Radio Button
orangeButton.setName("fruitRadioGroup");
orangeButton.setValue("ORANGES");
}


public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

//You can then obtain the selected radio button in your processFormRequest() as follows:

String radioGroupValue = pageContext.getParameter("fruitRadioGroup");
}


A know issue comes while implementing Radio Group refer to below link for more details:
Value that you need to set declaratively

Wednesday, April 29, 2009

TO Find @ in column

if (pageContext.getParameter("item1") != null)
{
OAViewObject oaviewobject1 = (OAViewObject)am.findViewObject("NewEmployeeVO1");

if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();

String email = row.getAttribute("Attribute1")+"";
System.out.println("Attribute1"+ email);
if( email.indexOf("@")<0)
throw new OAException("Invalid Email Entered", OAException.ERROR) ;
}
}

Thursday, April 16, 2009

Setting WhereClause in VOImpl

public class XXOAViewObjectImpl
{
/**This is the default constructor (do not remove)
*/
public XXVOImpl() {
}
public void initMajorList(String categoryID){
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, orgId);
setWhereClauseParam(1, categoryID);
setWhereClauseParam(2, compPlanId);
executeQuery();

}



}

The JDBC Tutorial: Chapter 3 - Advanced Tutorial

http://java.sun.com/developer/Books/JDBCTutorial/

Important Profile Options in OAF

FND_Diagnostics


Setting the FND : Diagnostics (FND_DIAGNOSTICS) profile option to "Yes" will enable the diagnostics global button to be rendered on the screen. Pressing this button brings the user to an interface where the user can choose what type of logged messages to display.


Personalization Levels


Personalizations can be enabled at the function, site, operating unit or responsibility level. Personalizations at lower levels override personalizations at higher levels. Values inherit the definition from the level immediately above unless changed.


FND: Personalization Region Link Enabled :
Valid values:  Yes - renders the "Personalize  Region" links above each  region in a page. Each link  takes you first to the Choose Personalization Context page, then to the Page Hierarchy Personalization page with focus on the region node from which  you selected the "Personalize  Region" link.


Personalize Self-Service Defn – Set this profile to Yes to allow personalizations.


Disable Self-Service Personalization - Yes will disable all personalizations at any level.


FND: Personalization Document Root Path (new in 11.5.10) - Set this profile option to a tmp directory with open (777)  permissions for migrating personalizations between instances.




How to See Log on Page


Enable profile Option FND_Diagnostics to "Yes" at User OR Site Level.


In Controller write this code:-
pageContext.writeDiagnostics(this, "Checking profile options", 1);


In Application Module write this code
getOADBTransaction().writeDiagnostics(this, "Checking Profile Option", 1);


Now to see log on screen Click on “Diagnostics” on Page [Top right on page]



Then Choose Show Log on Screen from the picklist and choose log level as Statement Level and Click on Go




Onion Architecture of OA Framework

OA Framework can be extracted into a series of concentric layers, like an onion.

Each layer only “knows”about the layers below it.The core layer represents the database and the surface layer represents the application pages. In between is a number of business logic and user interface layers. This layering allows for generic code and components to be implemented at the inner layers to maximize their reuse across the outer layers.

For example, attribute validation is implemented at the Entity Object (a BC4J object-oriented representation of a database table in the middle tier) level.





How to capute current row in Table Region

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

{

super.processFormRequest(pageContext, webBean); OAApplicationModule am =
(OAApplicationModule)pageContext.getApplicationModule(webBean);

String event = pageContext.getParameter("event");
if ("").equals(event))
{
// Get the identifier of the PPR event source row
String rowReference =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Serializable[] parameters = { rowReference };
// Pass the rowReference to a "handler" method in the application module.

am.invokeMethod("", parameters);
}
}
 
In your application module's "handler" method, add the following code to access the source row:


OARow row = (OARow)findRowByRef(rowReference);

if (row != null)

{
...
}

How to compare two dates

import oracle.jbo.domain.Date;

Date scoStartDate = null;
Date scoEndDate = null;
 
scoStartDate = (Date)rowi.getScoRoleStartDate();  // Capturing dates from RowImpl
scoEndDate = (Date)rowi.getScoRoleEndDate();  // Capturing dates from RowImpl
 
java.sql.Date javaSqlDate = scoStartDate.dateValue();

if (scoEndDate.dateValue().before(javaSqlDate))
{
           //throw Exception
}

Prepared Statement - Controller

Controller - ProcessFormRequest Code

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

try

{


Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();

String Query = "SELECT count(*) count from XX_PA_SCO_V where project_id=:1 and CI_ID is not null";

PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1, project_id);
for(ResultSet resultset = stmt.executeQuery(); resultset.next();)
{
pageContext.writeDiagnostics(this, "Query Executed", 1);
result = resultset.getInt("count");;
pageContext.writeDiagnostics(this, "Query Executed"+ result, 1);
}
}

catch(Exception exception)

{ 
throw new OAException("Error in Staffing Query"+exception, OAException.ERROR);
}

if(result >0)
{
throw new OAException("One or more Scope Change Order is existing on this project", OAException.INFORMATION);
}


Callable Statement in Controller

import java.sql.CallableStatement;

import java.sql.Types;
import oracle.apps.fnd.framework.OAApplicationModule;

import oracle.apps.fnd.framework.OAException; 
import oracle.apps.fnd.framework.server.OADBTransaction; 
  
try 

{
Connection conn = (Connection)oapagecontext.getApplicationModule(oawebbean).getOADBTransaction().getJdbcConnection();

CallableStatement cs = conn.prepareCall("{call XX_UPDATE_SCO_DETAILS_PKG.SCO_ADD_ON_WORK(?,?,?,?,?,?,?)}"); 

cs.setString(1, Proj_ID);
cs.setString(2, SCOID);
cs.setString(3, Assign_ID);
cs.setString(4, "ADD_NEW_RESOURCES");
cs.setString(5, strStartDate);
cs.setString(6, strEndDate);
cs.registerOutParameter(7, Types.VARCHAR);
cs.execute();
error_mess = cs.getString(7);
if(!StringUtils.isNullOrEmpty(error_mess))
{
throw new OAException("Error in saving data in custom table OR Updating LOE: "+error_mess);
}
conn.commit();
cs.close();
}
catch (SQLException sqle)
{
throw OAException.wrapperException(sqle);
}
Debug.log(oapagecontext, this, "Callabe Statement Executed", 3);




Friday, April 10, 2009

How to return array from Application Module

Controller Code

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import oracle.apps.fnd.framework.OAException; 
  

Serializable paras[] = {employee_id};
Object result[] = new Object[10]; // declaring result of Array Type
result = (Object[])am.invokeMethod("getparameters", paras); // Calling AM Method

String userid = (String)result[0]; // Capturing value from Array
String userName = (String)result[1]; // Capturing value from Array


Application Module Code

public Object[] getparameters(String employeeid)
{
ResultSet resultset = null;
int employee_id = Integer.parseInt(employeeid);

Object result[] = new Object[10];
OADBTransaction oadbtransaction = getOADBTransaction();
Debug.write(oadbtransaction, this, "Employee id is " + employee_id, 1);

try
{
Connection conn = getOADBTransaction().getJdbcConnection();
String query = "sselect user_id, user_name from fnd_user where employee_id=:1";

PreparedStatement stmt = conn.prepareStatement(query);
stmt.setInt(1, employee_id);

for(resultset = stmt.executeQuery(); resultset.next(); 
{

result[0] = resultset.getString("user_id");
Debug.write(oadbtransaction, this, "Project Number is " + result[0], 1);

result[1] = resultset.getString("user_name");
Debug.write(oadbtransaction, this, "Project ClassCode is " + result[1], 1);

}
}

catch(Exception e)

{
Debug.write(oadbtransaction, this, "Exception " + e.getMessage(), 1);
}
return result; // Returning result array to Controller
}

Creating VO at RunTime in Controller OR Dynamically created VO

ViewObject viewobject = oapagecontext.getApplicationModule(oawebbean).findViewObject("ObtainProjectId");


if(viewobject == null)
{
String s14 = "SELECT project_id FROM PA_PROJECTS_ALL WHERE segment1 =:1";
viewobject = oaapplicationmodule.createViewObjectFromQueryStmt("ObtainProjectId", s14);
}

viewobject.setWhereClauseParam(0, s5);
viewobject.executeQuery();
int i = viewobject.getRowCount();
if(i != 1)

{
Debug.log(oapagecontext, this, "Error : Project Number is Invalid or not unique", 3);
OAException oaexception4 = null;
oaexception4 = new OAException("PA", "PA_PROJECT_NUMBER_INVALID");
oaexception4.setApplicationModule(oaapplicationmodule);
throw oaexception4;
}

oracle.jbo.Row row = viewobject.last();

if(row != null)
{
Object obj2 = row.getAttribute(0);
if(obj2 != null)
{
s3 = obj2.toString();

if(s3 != null)
{
oapagecontext.putTransactionValue("paProjectId", s3); // Capturing projectid in Session

if(oaapplicationmodule.findViewObject("AddNewAssignmentsVO") != null)

{
oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().setAttribute("ProjectId", s3);
}
}
}
}

Wednesday, April 8, 2009

Getting & Setting Value

Capturing the value from VO and setting Explictiy in EO



import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.OARow;


public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
   super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);


OAViewObject oaviewobject1 =(OAViewObject)am.findViewObject("NewEmployeeVO1");
if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();
String fullName = (String)row.getAttribute("FullName");

OAViewObject vo1 = (OAViewObject)am.findViewObject("EmployeeEOVO1");
vo1.reset();
if (vo1 != null)
{
do
{
if(!vo1.hasNext())
break;
vo1.next();
EmployeeEOVORowImpl lcerl = (EmployeeEOVORowImpl)vo1.getCurrentRow();
lcerl.setFullName(fullName);

}while(true);
}
}

Convert dateToString | stringToDate

Controller Code:-

Date date = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("StartDate");
Date edate = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("EndDate");


if (date != null && edate != null)
                       {
                        String Xs11 = oapagecontext.getOANLSServices().dateToString(date);
                        String Xs12 = oapagecontext.getOANLSServices().dateToString(edate);
}

In the same way we can convert String to Date
oapagecontext.getOANLSServices().stringToDate("xxxx");

Creating View Object and MessageChoiceBean Programatically

Controller Code
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
String sMode = "test";
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject oaviewobject = (OAViewObject)am.findViewObject("xxScoResourceVO1");
if(oaviewobject == null)
{
oaviewobject = (OAViewObject)am.createViewObject("xxScoResourceVO1","xx.oracle.apps.pa.poplist.server.xxScoResourceVO");
}
      
oaviewobject.setWhereClause("DESCRIPTION IS NULL OR DESCRIPTION = '" + sMode + "'"); //Setting where clause Dynamically of Poplist VO

oaviewobject.executeQuery();
OAMessageChoiceBean oamessagechoicebean = (OAMessageChoiceBean)createWebBean(pageContext, "MESSAGE_POPLIST");
oamessagechoicebean.setPrompt("Back");
oamessagechoicebean.setListViewObject(pageContext, oaviewobject);
oamessagechoicebean.setListDisplayAttribute("Meaning");
oamessagechoicebean.setListValueAttribute("LookupCode");
  
oamessagechoicebean.setName("xxAddAsgmtApplyAction");
oamessagechoicebean.setAllowBlankValue(false);
oamessagechoicebean.setDefaultValue("RETURN_BACK"); //Setting Default Value
webBean.addIndexedChild(oamessagechoicebean);
}

How to capture its Value

String PoplistValue = oapagecontext.getParameter("xxAddAsgmtApplyAction");

Sunday, April 5, 2009

How to Capture LOV Event

if (pageContext.isLovEvent())
      {
      System.out.println("Inside LOV Event");
      String lovInputSourceId = pageContext.getLovInputSourceId();
//checking which lov event is fired.
//Below EmployeeLovInput is the ID of messageLovInput
   if ("EmployeeLovInput".equals(lovInputSourceId))
       {
         //Invokes AM Method 
            am.invokeMethod("setExtraInfo");
       }
}

The pageContext.isLovEvent method returns true/Fires if the event value is LOV_UPDATE (meaning the user selected a value from the LOV modal window), or LOV_VALIDATE (meaning the user tabbed out of the LOV input field on the base page).

Things good to know

Validation View Object - A view object created exclusively for the purpose of performing light-weight SQL validation on behalf of entity objects or their experts.


Validation Application Module - An application module created exclusively for the purpose of grouping and providing transaction context to related validation view objects. Typically, a standalone entity object or the top-level entity object in a composition would have an associated validation application module.


Root Application Module - Each pageLayout region in an OA Framework application is associated with a "root" application module which groups related services and establishes the transaction context.

This transaction context can be shared by multiple pages if they all reference the same root application module, and instruct the framework to retain this application module (not return it to the pool) when navigating from page to page within the transaction task.


View Link - Establishes a master/detail relationship between two view objects


Entity Expert - A special singleton class registered with an entity object (EO) that performs operations on behalf of the EO.

Association Object - BC4J association objects implement the relationships between entity objects. For example, a purchase order header can reference a supplier, or it can own its order lines.

Attribute Set - Bundles of region or item properties that can be reused either as is or with modifications. For example, all buttons sharing the same attribute set would have the same label and Alt text.

How to call SRS Window in OAF

Controller PFR Code
import oracle.apps.fnd.framework.webui.OAUrl;

StringBuffer l_buffer = new StringBuffer();
StringBuffer l_buffer1 = new StringBuffer();
l_buffer.append("javascript:mywin = openWindow(top, '");
l_buffer1.append("&akRegionApplicationId="+"0");
l_buffer1.append("&akRegionCode="+"FNDCPREQUESTVIEWPAGE");
l_buffer1.append("&retainAM=Y");
String url = "/OA_HTML/OA.jsp?page="+l_buffer1.toString();
OAUrl popupUrl = new OAUrl(url, OAWebBeanConstants.ADD_BREAD_CRUMB_SAVE );
String strUrl = popupUrl.createURL(pageContext);
l_buffer.append(strUrl.toString());
l_buffer.append("', 'lovWindow', {width:750, height:550},false,'dialog',null);");
pageContext.putJavaScriptFunction("SomeName",l_buffer.toString());

Thanks
--Anil

Custom CSS

http://forums.oracle.com/forums/thread.jspa?threadID=1054912&tstart=0

Calling Procedure

AM Code:

public String CreateInvoice(String pamount,String ptype,String pnum,String perror)
{

String perror = null;
try
{
Connection conn = getOADBTransaction().getJdbcConnection();
CallableStatement cstmt = conn.prepareCall("{call add_invoice_proc(?,?,?,?)}");
cstmt.setString(1,pamount);
cstmt.setString(2,ptype);
cstmt.setString(3,pnum);
cstmt.registerOutParameter(4,Types.VARCHAR);
System.out.println("before calling");
cstmt.execute();
perror = cstmt.getString(4);/*****getting the out parameter*****/
System.out.println("after calling");
System.out.println("error is "+perror);
cstmt.close();
}
catch(Exception e)
{
e.printStackTrace();
}

return perror;
}



public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Insert")!=null)
{
String amount = pageContext.getParameter("InvoiceAmount");
String type = pageContext.getParameter("InvoiceTypeLookupCode");
String number = pageContext.getParameter("InvoiceNum");
String error = "";
OAApplicationModule am = pageContext.getApplicationModule(webBean);
Serializable [] params = {amount,type,number,error};
am.invokeMethod("CreateInvoice",params);
System.out.println("getting the out param in CO");
String returnmsg =(String)am.invokeMethod("CreateInvoice",params);
System.out.println("after getting");
System.out.println("errorstring is "+returnmsg);
if (returnmsg != null)
{
throw new OAException(returnmsg,OAException.ERROR);
}
if (returnmsg==null)
{
throw new OAException("Invoice created Successfully",OAException.CONFIRMATION);
}
}
}

Import & Export Commands 11i & R12

//Note : Need to run these commands from window command prompt
// For 11i - JDevInstallDir\jdevbin\jdev\bin>
// For R12 - JDevInstallDir\jdevbin\oaext\bin;

import d:\jdevhome\jdev\myprojects\xx\oracle\apps\per\webui\EmployeeRN.xml -rootdir d:\jdevhome\jdev\myprojects -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=camoradb9.xx.com)(PORT=1525))(CONNECT_DATA=(SID=DEV)))"

jpximport d:\Employee.jpx -userId 1 -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=camoradb9.xx.com)(PORT=1525))(CONNECT_DATA=(SID=DEV)))"

export /oracle/apps/per/employee/webui/employeeRN -rootdir d:\jdevhome\jdev\myprojects -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=camoradb9.xx.com)(PORT=1525))(CONNECT_DATA=(SID=DEV)))"


//XMLImporter Command: Run this command on server from $JAVA_TOP 
java oracle.jrad.tools.xml.importer.XMLImporter $JAVA_TOP/xxx/oracle/apps/pa/sco/webui/StaffingRN.xml -rootdir  $JAVA_TOP -userId 1 -username apps -password xxx -dbconnection "(description = (address_list = (address = (community  = tcp.world)(protocol = tcp)(host = camoradb8.xxx.com)(port = 1532)))(connect_data = (sid =EAFIN11)))" 
 
// XML Exporter Command : Run this command on server from $JAVA_TOP
java oracle.jrad.tools.xml.exporter.XMLExporter /xx/oracle/apps/pa/projects/webui/ProjectSummaryPG -rootdir $JAVA_TOP -username apps -password atgapps -dbconnection "(description = (address_list = (address = (community = tcp.world)(protocol = tcp)(host =CAMORADB8.xxx.com)(port = 1522)))(connect_data = (sid = EAFIN1)))"

Programmatically Search / Custom Search Code

Controller Code

 // In the controller
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(webBean);
 ForumsAMImpl am1 = (ForumsAMImpl)pageContext.getApplicationModule(webBean);
 if(pageContext.getParameter("submit") != null)
    {
         pageContext.writeDiagnostics("Anil", "Calling Execute Method ", 1);
          am1.ExecuteQuery(pageContext, webBean);
   
    }
}

ApplicationModule Code

public void  ExecuteQuery(OAPageContext pageContext, OAWebBean webBean)
{
 String supID = pageContext.getParameter("SuppID1")+"";
 String supName = pageContext.getParameter("SupplierName")+"";
 String supSite = pageContext.getParameter("SupplierSiteID")+"";

 XXSupplierSiteVOImpl vo = getXXSupplierSiteVO1();
  
 Debug.log(pageContext, "SearchAMImpl", "SuppID1 = " + supID, 1);
 Debug.log(pageContext, "SearchAMImpl", "SupplierName = " + supName, 1);
 Debug.log(pageContext, "SearchAMImpl", "SupplierSiteID = " + supSite, 1);

   String strWhereClause = "";
   Object paramArray[] = new Object[10];
   int i = 1;

 if(!StringUtils.isNullOrEmpty(supName))
 {

  if(StringUtils.isNullOrEmpty(strWhereClause))
  {
    Debug.log(pageContext, "SearchAMImpl", "supName = " + supName, 1);
    strWhereClause = " SITE_NAME like :" + i;

    Debug.log(pageContext, "SearchAMImpl", " strWhereClause = " + strWhereClause, 1);
    paramArray[i] = supName+ "%";
   } 

else
    {
     i++;
     strWhereClause = strWhereClause + "AND SITE_NAME like :" + i;
     Debug.log(pageContext, "SearchAMImpl", "supName in else = " + i, 1);
     paramArray[i] = supName;
     }
     }
       
     Debug.log(pageContext, "SearchAMImpl", "Above SupplierID Check " + supID, 1);
     if(!StringUtils.isNullOrEmpty(supID))
      {
       Debug.log(pageContext, "SearchAMImpl", "Inside SupplierID Check " + supID, 1);
         
       if(StringUtils.isNullOrEmpty(strWhereClause))
       {
         strWhereClause = " SUPPLIER_ID = :" + i;
         Debug.log(pageContext, "SearchAMImpl", " strWhereClause = " + strWhereClause, 1);
         paramArray[i] = supID;
         Debug.log(pageContext, "SearchAMImpl", " supID is = " + supID, 1);
        }
      
      else
        {
          Debug.log(pageContext, "SearchAMImpl", "SUPPLIER_ID WhereClause ELSE " + supID, 1);
          i++;
          strWhereClause = strWhereClause + " and SUPPLIER_ID like :" + i;
          paramArray[i] = supID;
          Debug.log(pageContext, "SearchAMImpl", "paramArrayE " + paramArray[i], 1);
        }
       }

      Debug.log(pageContext, "SearchAMImpl", "Above supSite Check " + supSite, 1);
       if(!StringUtils.isNullOrEmpty(supSite))
        {
          Debug.log(pageContext, "SearchAMImpl", "Below supSite Check " + supSite, 1);
          if(StringUtils.isNullOrEmpty(strWhereClause))
        {
           strWhereClause = " SUPPLIER_SITE_ID = :" + i;
           paramArray[i] = supSite;
        } 

    else
         {
          Debug.log(pageContext, "SearchAMImpl", "SUPPLIER_SITE_ID WhereClause ELSE " + supSite, 1);
         i++;
         strWhereClause = strWhereClause + " AND SUPPLIER_SITE_ID = :" + i;
         paramArray[i] = supSite;
         Debug.log(pageContext, "SearchAMImpl", "paramArray " + paramArray[i], 1);
         }
        }
    
          vo.setWhereClause(null);
          vo.setWhereClauseParams(null);
     
         Debug.log(pageContext, "SearchAMImpl", "Anil SetWhereClause" + strWhereClause, 1);
         Debug.log(pageContext, "SearchAMImpl", "i value is " + i, 1);
         vo.setWhereClause(strWhereClause);
       
         for(int j = 0; j < i; j++)
          {
            Debug.log(pageContext, "SearchAMImpl", "bind index " + j, 1);
            if(paramArray[j + 1] != null)
              {
                 vo.setWhereClauseParam(j, paramArray[j + 1]);
                Debug.log(pageContext, "SearchAMImpl", "bind values from Array " + paramArray[j + 1], 1);
             }
          }

          Debug.log(pageContext, "SearchAMImpl", " **** Query 2 = " + vo.getQuery(), 1);
          vo.executeQuery();
 }

Deploying Personalizations

The Functional Administrator responsibility provides a simple UI that lets you both export meta data to XML files, and import XML files into a MDS repository.


1. You have to  set the profile option FND: Personalization Document Root Path (FND_PERZ_DOC_ROOT_PATH) to a root directory in your file system where your files are to be exported to or imported from.


2. Log in to the Oracle E-Business Suite under the Functional Administrator responsibility.

3. Select the Personalizations tab, then select the Import/Export sub tab.

4. Select the pages, regions or packages you wish to export, then select Export to File.

5. Once you export your meta data to XML files on the file system, you should login to the other Oracle E-Business Suite environment that you want to import these files.


6. To import the XML files from your file system into another MDS repository, login to the other Oracle E-Business Suite environment as a Functional Administrator. Select the Personalizations tab, then select the Import/Export sub tab. Select Exported Personalizations from the side navigation menu to display the Exported Personalizations page.



7. Select all the documents you wish to import and choose Import from File System.




You can review the personalization through  JDR_UTILS . It is a PL/SQL package that allows you to evaluate the list of personalization documents that are in your MDS repository.


For example, to see all
the personalization documents for the Notifications Worklist Table, execute the following command:

exec
jdr_utils.listcustomizations('/oracle/apps/fnd/wf/worklist/webui/AdvancWorklistRG');

Diagnosing Personalization Problems

About this Page link shows document path and all personalization documents

• MDS pages saved under /mds/comp/sub/file.xml
• XML files imported into MDS repository at customer site


Use the Functional Administrator Responsibility / Application Catalog Tool to disable individual personalization documents

• Turn off personalizations for the entire instance by setting the following profile to ‘Yes’
• Disable Self-service Personal / FND_DISABLE_OA_CUSTOMIZATIONS


Use SQL*Plus to see personalization registration
• Turn on diagnostic messaging in SQL*Plus
• SQL> set serveroutput on

//Review what personalization documents exist for a given page

• execute jdr_utils.listcustomizations('/oracle/apps/fnd/wf/worklist/webui/FullWorklistPG');

//Review a personalization document

• execute jdr_utils.printdocument('/oracle/apps/fnd/customizations/user/2662/wf/worklist/webui/
FullWorklistPG');

// Delete a personalization document

• execute jdr_utils.deletedocument('/oracle/apps/fnd/customizations/user/2662/wf/worklist/webui/
FullWorklistPG');

Diagnosing Extension Problems

Make sure to import the .jpx file with the substitution into MDS using JPXImporter

• Use the 'About this Page' link to find all dependent objects and make sure substitutions of your extended objects were successful

• Enabled through FND_DIAGNOSTICS profile



// Check to see if substitution file was uploaded

execute jdr_utils.listcustomizations('/oracle/apps/fnd/framework/toolbox/tutorial/server/PoSummaryVO');

// Review a substitution definition

execute jdr_utils.printdocument('/oracle/apps/fnd/framework/toolbox/tutorial/server/customizations/si
te/0/PoSummaryVO');


// delete a substitution definition

execute
jdr_utils.deletedocument('/oracle/apps/fnd/framework/toolbox/tutorial/server/customizations/site/0/PoSummaryVO);

commit;

Enable Debug Log on OAF Page

We can enable logging by setting the below profile option:-
• FND: Debug Log Enabled profile set to ‘Yes’
• Turn on low level statement logging for a single user to monitor
• FND: Debug Log Level= Statement


Another way of gathering the same info is the following:


• First enable profile option FND: Diagnostics then
• At the end of the existing URL add:  &aflog_level=Statement&aflog_module=*

• Use '*' for wildcard, not '%'. '%' is a special URL character)

Example:
• http://host:port/OA_HTML/OA.jsp?OAFunc=OAHOMEPAGE&aflog_level=STATEMENT&aflog_module=pa

You can see the log on screen by using by below code in your controller OR in Application ModuleImpl

For AM

getOADBTransaction().writeDiagnostics(this, "I am in the Application Module", 1);

For Controller


 pageContext.writeDiagnostics(this, "I am in Controller PFR", 1);

How to hide OAImageBean in Controller



import oracle.apps.fnd.framework.webui.beans.OAImageBean;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.OARow;

 public void processRequest(OAPageContext pageContext, OAWebBean webBean)

{
 super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

String userid = pageContext.getUserId()+"";
if (userid.equals(pageContext.getUserId()+""));
{
OAViewObject oaviewobject1 =(OAViewObject)am.findViewObject("EmployeeEOVO1");
OAViewObject svo =(OAViewObject)am.findViewObject("StatusPVO1");
OARow row1 = (OARow)svo.first();

if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();

String fullName = (String)row.getAttribute("Attribute1");

if (fullName.equals("A"))

{
OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved");
OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected");
OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess");
imagebean.setRendered(true);
imagebean1.setRendered(false);
imagebean2.setRendered(false);
}

else if (email.equals("R"))
{
OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved");
OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected");
OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess");
imagebean.setRendered(false);
imagebean1.setRendered(true);
imagebean2.setRendered(false);

}

else if (email.equals("W"))
{

OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved");
OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected");
OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess");
imagebean.setRendered(false);
imagebean1.setRendered(false);
imagebean2.setRendered(true);

}

else

{
System.out.println("Inside ELSE");
OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved");
OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected");
OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess");
imagebean.setRendered(false);
imagebean1.setRendered(false);
imagebean2.setRendered(false);

}
}
}
}

Deployment of Page in APPS - OAF

The steps in brief are :

· Development of the TestPagePG.xml page in local machine
· FTP the related source code/files to the Oracle APPS environment.
· Importing the page to the Database through Import Command.
· Registration of the page in the Oracle Apps environment.


On project compilation the class files along with xml files are generated in Myclasses.


The Folder Structure for xml pages and respective Controllers are as below
C:\Jdevhome\Jdev\myclasses\xxx\oracle\apps\fnd\framework\webui\*
C:\Jdevhome\Jdev\myclasses\xxx\oracle\apps\fnd\framework\server\*

The First step will be to move the files into the JAVA_TOP with the help of any FTP Tool.

Just drag and dropped the xxx  folder from local m/c to Apps Java top path.


Importing the XML files:

Run the import scripts for the Page and Regions.

The import command is


import C:\Jjdevhome\jdev\myprojects\xx\oracle\apps\fnd\framework\webui\TestPagePG.xml -rootdir C:\jdevhome\jdev\myprojects -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.255.35.20)(PORT=1525))(CONNECT_DATA=(SID=DEV)))"

The command is to be run from Jdeveloper/Jdevbin/Jdev/Bin from command prompt.

Registering the Main Page in APPS.


Login through System Administrator Resp.

Select Application -- Function.

1. Enter the Function Name, User Function Name and Description

2. Enter Properties (Tab) Type as SSWA jsp function






3. In Web HTML Tab enter the page path
OA.jsp?page=/xxx/oracle/apps/fnd/framework/webui/TestPG

Attach the function with a desired menu and then run from the respective responsibility.

Last and the important step :-- DONOT forget to bounce the Appache server.





How to Bounce Apache server in 11i & R12

1. Connect to the server through Putty.


Now write
1. cd $COMMON_TOP.


2. cd admin/scripts/



Now write adapcctl.sh stop and once the appache is stopped write adapcctl.sh start to start the Appache server.

To bounce Appache in R12

1. adapcctl.sh stop
2. adoacorectl.sh stop

3. adapcctl.sh start
4. adoacorectl.sh start

These scripts are in $INST_TOP/admin/scripts












Wednesday, April 1, 2009

Change the date Format from YYYY-MM-DD to DD-MM-YYYY

In Controller

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.text.DateFormat;
import java.util.Date;

String newProjStartDate,newProjEndDate, sConvertNewStartDate, sConvertNewEndDate = null;


newProjStartDate= (String)pageContext.getSessionValue("newstartdate");
newProjEndDate= (String)pageContext.getSessionValue("newenddate");

try


{
DateFormat formatter ;
Date date, date1, date2, date3;
formatter = new SimpleDateFormat("yyyy-MM-dd");
date = formatter.parse(newProjStartDate);
date1 = formatter.parse(newProjEndDate);

pageContext.writeDiagnostics(this, "Anil date is =" + date, 1);
pageContext.writeDiagnostics(this, "Anil date1 is =" + date1, 1);

SimpleDateFormat formatterNew = new SimpleDateFormat("dd-MMM-yyyy");
sConvertNewStartDate=formatterNew.format(date);
sConvertNewEndDate=formatterNew.format(date1);

pageContext.writeDiagnostics(this, "sConvertStartDate date is =" + sConvertNewStartDate, 1);
pageContext.writeDiagnostics(this, "sConvertEndDate date1 is =" + sConvertNewEndDate, 1);

}

catch (ParseException e)

{
throw new IllegalArgumentException("Encountered Date format error "+ e);
}