Friday, April 25, 2008

ADF Learning 7 - Show Hide button in ADF faces

Read this doc on Scribd: Lesson 7 - Show Hide button in ADF faces

ADF Learning 6 - Dependent List Boxes

Read this doc on Scribd: ADF Learning 6 - Dependent List Boxes

ADF Learning 5 - Search an Employee

Read this doc on Scribd: ADF Learning 5 - Search an Employee

ADF Learning 4 - Create Employee page

Read this doc on Scribd: ADF Learning 4 - Create Employee page

ADF Learning 3 - Navigating to detail page

ADF Learning 2 - Displaying Data on the page

ADF Learning 1 - Hello World

Read this doc on Scribd: ADF Learning 1 - Hello World

Thursday, April 24, 2008

Starting up with ADF

Few weeks back I started learning ADF. I have just a start it. Most of the learnings shared here are based on the HR schema tables. Do let me know if you find any diffculty in any of the learnings.
To view all the post clealy click on the Scribd icon in the tool bar.

Tuesday, April 8, 2008

Help Questions in OAF.......part -3

Q: To construct an oracle.jbo.domain.Date object for current JVM system time?
Answer:
oracle.jbo.domain.Date currentJvmDate = new oracle.jbo.domain.Date(System.currentTimeMillis());
Q: To construct an oracle.jbo.domain.Date object for current database system time?
Answer:
oracle.jbo.domain.Date currentDbDate =rootAM.getOADBTransaction().getCurrentDBDate();
Q: To determine if an oracle.jbo.domain.Date is the passedDate?
Answer:
public boolean isPassedDate(Date value)
{
// ensures that this mandatory attribute has a nonnull
value.
if (value != null)
{
OADBTransaction transaction = this.getOADBTransaction();
long sysdate = transaction.getCurrentDBDate().dateValue().getTime();
long startDate = value.dateValue().getTime();
if (startDate < sysdate)
{
return true;
}
}
return false;
}
Q: To round off the real number upto two digits?
Answer:
public String roundOffToTwoDigit(String number)
{
DecimalFormat formatter= new DecimalFormat("###.##");
double numberD = Double.parseDouble(number);
return formatter.format(numberD);
}
public double roundOffToTwoDigit(double number)
{
try
{
DecimalFormat formatter= new DecimalFormat("#.00");
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
return new Double(formatter.format(number)).doubleValue();
}
catch(java.lang.NumberFormatException e)
{
e.printStackTrace();
}
return 0.0;
}
Q: I have an entity object-based view object and I use vo.clearCache.However I am getting oracle.jbo.TooManyObjectsException?How to solve this?
Answer:
When you clear the view object cache with vo.clearCache(), it does NOT clear the entity cache nor change the states of entities. Thus, if you try to insert the row with a key value that already exists in the entity cache; you get TooManyObjectsException.The solution is to remove on all
the rows in the view object.
Q: When I am trying to insert a record through OAF page, I am getting oracle.jbo.TooManyObjectsException? How to solve this?
Answer:
Possible reason could be of inserting the record with duplicate primary key.
Q: How do I determine the transaction state -- that is, whether changes have been made to view objects or not?
Answer:
We can use
-->ApplicationModule.getTransaction().isDirty() - This method tells you whether the transaction contains any changes in the view objects. This works for transactions made by entity object-based view objects only.
-->OAViewObject.isDirty() - This method tells you whether a particular view object contains changes or not. This works for both entity object-based view objects and view objects
based on OAPlsqlViewObjectImpl
--> Or we can achieve it declarativaly by setting the Warn About changes property against the item for which we want the System to generate the Warn About change warning. But if your view Contains many transient variables which are getting defaulted at page load, then you can use the following method:-
/* @sourceVO: source VO contains the data in the UI
* @destVO: dest VO contains the data fetched from the
database, should not be
* based on EO
*/
private boolean isVODataDirty(ViewObjectImpl sourceVO,
ViewObjectImpl destVO)
{
boolean dirtyDataFlag=false;
if (sourceVO == null destVO == null)
{
return false;
}
else if(sourceVO.getRowCount()!=destVO.getRowCount())
{
return true;
}
AttributeDef[] attrDefs = sourceVO.getAttributeDefs();
int attrCount = (attrDefs == null)? 0 : attrDefs.length;
/*if no attributes are there in the VO*/
if (attrCount == 0)
{
return false;
}
/* Create a row set iterator on the source view object
to use for copy operation*/
RowSetIterator compareIter = sourceVO.findRowSetIterator("compareIter");
if (compareIter == null)
{
compareIter = sourceVO.createRowSetIterator("compareIter");
}
int count=0;
/*Sets the range size for the iterator,-1 for all
rows are to be included.*/
destVO.setRangeSize(-1);
/*loop for the VO rows*/
while (compareIter.hasNext())
{
Row sourceRow = compareIter.next();
Row destRow = destVO.getRowAtRangeIndex(count);
/*loop for the VO Attribute*/
for (int i = 0; i < attrCount; i++)
{
byte attrKind = attrDefs[i].getAttributeKind();
/*compare the data only if the attribute
is persistent*/
if(attrKind==AttributeDef.ATTR_PERSISTENT)
{
String attrName=attrDefs[i].getName();
if (destVO.lookupAttributeDef(attrName) != null)
{
Object sourceAttrVal = sourceRow.getAttribute(attrName);
Object destAttrVal = destRow.getAttribute(attrName);
if(destAttrVal!=null && sourceAttrVal!=null)
{
if(!sourceAttrVal.equals(destAttrVal))
{
dirtyDataFlag=true;
compareIter.closeRowSetIterator();
return dirtyDataFlag;
}
}
/*if values are not equal then it
means data is dirty*/
if((sourceAttrVal==null && destAttrVal!=null)
(sourceAttrVal!=null && destAttrVal==null))
{
dirtyDataFlag=true;
compareIter.closeRowSetIterator();
return dirtyDataFlag;
}
}
}
}
count++;
}
compareIter.closeRowSetIterator();
destVO.reset();
/*data is not dirty*/
return dirtyDataFlag;
}
Q: When I am executing the VO query and after that fetching the attribute value from the VO, getting the NullPointerExecption?How to handle it?
Answer:-When you execute the VO.executeQuery() method, and if your query is fetching the record, then row pointer is at position -1. Either call the vo.first() method or call vo.setCurrentRowRangeIndex(0);
Q: I have two radio buttons with are the part of the same group, when I am submitting the page, control is jumping in to the last radio button? How I can solve this problem?
Answer:-Just put your individual radio button under the flowlayout which intern should be put under the cell format.
Q: I have two advance tables in my page. And both of them have "Add Another Row" button, now How I can identify that which "Add Another button" is clicked?
Answer: By calling the pageContext.getParameter(SOURCE_PARAM) will return the name
of the Advance table against which the Add Another Radio button is clicked.
Q: I have two radio buttons in my page. When I am submitting the page, the control is jumping to last radio button in my page?
Answer:
Use messageRadioButtons and group them under same name and add each radio button under the separate cellformat region.
Q: I want to check the XML file which I have imported to the Server in MDS repository?
Answer: Execute following command in SQL exec JDR_UTILS.printDocument('');
example
exec
JDR_UTILS.printDocument('/who/oracle/apps/xxwrp/prt/whoreg/
webui/XXWRP_GoodsRegistrationPG');
And to list of the PG files in particular top, execute the
following command:-
exec JDR_UTILS.listDocuments('path');
example
exec
JDR_UTILS.listDocuments('/who/oracle/apps/xxwrp/prt/whoreg/
webui/');
Q: Is there a way to determine if someone has used the personalize links on a Self-Service Web Applications page?
Answer:
Here are several ways to identify if there are Personalization’s made to a page and what those
Personalization’s are:
1. The first and easiest way is to go to the page you want to check for Personalization’s, then click on the 'About this page' link at the bottom left of the page. Click on the Personalization tab. Then you should see a list of 'Effective Personalization’s', what elements have been customized and when they were customized/personalized.
2. Another way is to use the Functional Administrator. The first thing to do to use the Functional Administrator is to identify the Document Path. For example, go to the Notifications link from the Workflow User Web Applications responsibility, and then click on the Personalize Page link. Notice that the Document path for the Notifications page is: /oracle/apps/fnd/wf/worklist/webui/NotificationsPG. From the Functional Administrator responsibility Home page, click on the Personalization tab in the upper left hand corner. Insert the document path for the document you want to check - for example: Document Path = /oracle/apps/fnd/wf/worklist/webui/NotificationsPG and then click on the 'Go' button to get a list of Personalization’s for this page.
3. A third way to check to see if there are personalization’s on a page is to use sqlplus and run the
JDR_UTILS program. You will need the Document path to the page in question - again using the Document path for the Notifications page: /oracle/apps/fnd/wf/worklist/webui/NotificationsPG
Run the listDocuments function to drill down and find all documents that have been personalization’s under a certain Meta Data region:
Run from sqlplus:
set serveroutput on
exec
JDR_UTILS.listDocuments('/oracle/apps/fnd/wf/worklist/webui
/');
/oracle/apps/fnd/wf/worklist/webui/customizations/
Note, you do not include the Page ID (NotificationsPG) with this query. In my test case, notice that there are 'customizations' in this MDS region webui. The 'customizations' indicates that personalization’s have been made to the 'webui' region. Run the query again with the new path and notice that there are 'site' level customizations, although there could be other levels such as user, responsibility, ...:
exec
JDR_UTILS.listDocuments('/oracle/apps/fnd/wf/worklist/webui
/customizations/');
/oracle/apps/fnd/wf/worklist/webui/customizations/site/
Run the query again with the new path and notice that the customizations are at site level '0':
exec
JDR_UTILS.listDocuments('/oracle/apps/fnd/wf/worklist/webui
/customizations/site/');
/oracle/apps/fnd/wf/worklist/webui/customizations/site/0/
Run the query one more time with the new path and notice that the customizations are made to the 'NotificationsPG':
exec
JDR_UTILS.listDocuments('/oracle/apps/fnd/wf/worklist/webui
/customizations/site/0/');
/oracle/apps/fnd/wf/worklist/webui/customizations/site/0/No
tificationsPG
Once we have identified a particular page or pages that have customizations/personalization, then we can use the printDocument to see what personalization’s have been made
to the page:
exec
JDR_UTILS.printDocument('/oracle/apps/fnd/wf/worklist/webui
/customizations/site/0/NotificationsPG');
-------------

version="9.0.5.4.89_554"
xml:lang="en-US"
customizes="/oracle/apps/fnd/wf/worklist/webui/NotificationsPG">




-------------
As you can see, rendered has been set to "false" for "MainRegion.NtfView". You can then use the deletedocument function to remove this personalization exec jdr_utils.deletedocument('/oracle/apps/fnd/wf/worklist/webui/customizations/site/0/NotificationsPG');

Q: How to remove a bad personalization from an OA Framework page?
Answer:
) Login to Oracle Applications with the system administrator responsibility
2) Update the Profile Option: "Disable Self-Service Personal" = YES
- This disables the rendering of all personalization that have been created.
- You can set this at the site or user level.
3) Navigate to the page you personalized.
4) Enter the personalization UI in the same way you did to create the personalization initially
5) Click the Delete button at the bottom of the page.
- This will remove the personalization from the page.
6) Go back to Oracle Apps with the system administrator responsibility
7) Re-enable personalizations by setting the "Disable Self- Service Personal" profile option to NO
Q: How to pass a Date to a VO for executing the Query?
Answer:
Oracle.jbo.domain.date dateToPass=;
java.sql.Date javaSqlDate=dateToPass.dateValue();
dateToPass = new Date(javaSqlDate);
vo.setWhereClauseParam(1,dateToPass);
vo.executeQuery();
Q: How I can bind the property of a UI widget to a VO attribute at design time and at run time?
Answer:
At design time we have to use SPEL. Suppose to have to bind the disable property of a UI widget to the VO attribute. Then specify ${oa..} against the disabled property of the UI item in the property inspector. For run time, get the handle of the bean. say
OAMessageLovInputBean beanObj = (OAMessageLovInputBean)webBean.findIndexedChildRecursive("<>");
beanObj.setAttributeValue(DISABLED_ATTR,new
OADataBoundValueViewObject(beanObj, "", ""));
Q: How I can change the values of the Categories (Category drop down) in the standard OAF Attachment page?
Answer:
String []maps=;
OAAttachmentTableBean attchmentBean=(OAAttachmentTableBean)webBean.findIndexedChi
ldRecursive("AttachmentTable");
attchmentBean.setCategoryMap(,maps,pageContext);
Q: How I can set the Currency Code(Currency format) for a particular UI field?
Answer:
String formatter = "USD";
OAMessageStyledTextBean regUSDAmtBean=(OAMessageStyledTextBean)webBean.findIndexedChildRecursive("USDTotalAmt");
if (regUSDAmtBean != null)
{
regUSDAmtBean.setAttributeValue(CURRENCY_CODE,formatter);
}
Q: How to get the handle to a particular row of the Advance table?
Answer:
--------------Inside CO---------------------------------------------------------------------
String rowReference =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Serializable[] params = { rowReference };
am.invokeMethod("getHandleToRow",params);
---------------------------------------------------------------------------------------------
------------Inside AM------------------------------------------------------------------------
public void getHandleToRow()
{
OARow row = (OARow)findRowByRef(rowReference);
-------
}

Thursday, April 3, 2008

Help Questions in OAF.......part -2

Q: How do I find whether 'Next' or 'Previous' links are clicked or not? (Classic and Advanced)?
Answer:
/*Call the following logic in processFormRequest method of
the web bean's controller that contains the table bean.*/
String value = pageContext.getParameter("value");
if (value != null)
{
int newValue = Integer.parseInt(value);
if (tableBean.getValue() < newValue)
// next pressed.
else
// previous pressed.
}
Q: Is there a method for setting the length of the fields in a poplist? It seems to be sized to the length of the largest value in the list?
Answer:
This is the standard HTML behavior. The only method available to you is to truncate the values being passed to the poplist.
Q: Is there any way to check whether a field from the base page, that an LOV is dependent on, is blank?
Answer:
In OA Extension, set the Required property to yes for the field (region item). If the field is blank, the LOV will generate an exception.
Q: How do I handle raising an unexpected database error and passing that back to the instantiating page?
Answer:
To handle database errors that occur within a PL/SQL procedure called through Java, code a standard exception handler for 'when others' within the PL/SQL procedure. The 'when others' exception handler should call FND_MSG_PUB.ADD_EXEC_MSG (pkg_name, proc_name,
substr(sqlerrm, 1, 240)). This registers the database error in the standard FND error stack.
You can then catch and throw that exception in the insertRow and updateRow methods using the procedure OAExceptionHelper.checkErrors (Tx, messageCount, returnStatus, messageData).
Q: To convert oracle.jbo.domain.Date ==> java.util.Date?
Answer:
oracle.jbo.domain.Date oracleDate = ;
java.sql.Date javaSqlDate = oracleDate.dateValue();
long javaMilliSeconds = javaSqlDate.getTime();
java.util.Date javaUtilDate = new java.util.Date(javaMilliSeconds);
Q: To convert java.util.Date ==> oracle.jbo.domain.Date?
Answer:
java.util.Date javaDate = ;
long javaMilliseconds = javaUtilDate.getTime();
java.sql.Date javaSqlDate = new java.sql.Date(javaMilliseconds);
oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(javaSqlDate);