Friday, March 14, 2008

Help Questions in OAF.......part -1

Q: How to group the Radio Buttons in a OAF page?
Answer:
Example:-
OAMessageRadioButtonBean amountBasedRBBean =
(OAMessageRadioButtonBean)
webBean.findIndexedChildRecursive("AmountBasedRB");
OAMessageRadioButtonBean rateBasedRBBean =
(OAMessageRadioButtonBean)
webBean.findIndexedChildRecursive("RateBasedRB");
amountBasedRBBean.setName("AmountRadioGroup");
amountBasedRBBean.setValue("A");
rateBasedRBBean.setName("AmountRadioGroup");
rateBasedRBBean.setValue("R");
Q: After clicking submit button in OAF page,processFormRequest doesn’t get called. How do I correct this?
Answer:
Possible Solution:-Go to Tools-->Preferences-->Embedded
OC4J--> and confirm that the "Default Local IP Address"
option is selected.
Q: Clicking "Add another Row" button in a table results to “state loss” error on the page. How should I resolve this? (Classic and Advanced)
Answer:
This happens when you have not executed the view object
associated with the table. For any successful table event,
the underlying table view object query must have been
executed before a table event is caused. In the case where
you don't want to display any rows when the page comes up,
yet want to select on "Add Another Row" to add rows into
the table, then before you add rows to the table, you must
properly initialize the view object.
Q: One of the most common errors we all face in OAF is "oracle.apps.fnd.framework.OAException:java.lang.NullPointerException". How should I resolve this?
Answer:
The primary cause of this error is beacuse of you are
trying to fetch the data from the VO, which
does't contains any data.
For example:-
1)XXWRP_ServiceRegVORowImpl
serviceRegVORow=(XXWRP_ServiceRegVORowImpl)getXXWRP_Service
RegVO1().getCurrentRow();
2)Date value=serviceRegVORow.getCompletionDate();
Now if the XXWRP_ServiceRegVO1 is not executed, then above
code will throw error at line number 2.To avoid this,
either handle NullPointerException or check if the
serviceRegVORow is null or not.
Q: How do find out the selected view object rows using the table selector? (Classic and Advanced)?
Answer: - Place this logic in your view object and invoke
it with invokeMethod from AM.
int fetchedRowCount = getFetchedRowCount();
if (fetchedRowCount > 0)
{
// Save the original range size and range start.
int savedRangeSize = getRangeSize();
int savedRangeStart = getRangeStart();
/* Alter the range size and start in this order to
prevent any accidental row fault-in from the
database. */
setRangeStart(0);
setRangeSize(fetchedRowCount);
Row[] rows = getAllRowsInRange();
for (int i = 0; i < fetchedRowCount; i++)
{
if(rows[i]!=null &&
"Y".equals(rows[i].getAttribute("SelectFlag")))
{
/*operation to be performed on row*/
}
}
}
/*Restore the range size and start. Do in the following
order to prevent any accidental row fault-in. Reverse
order upon restoring to a potentially smaller range size.*/
setRangeSize(savedRangeSize);
setRangeStart(savedRangeStart);

3 comments:

Pavan said...

Hi vikram,

It was a nice example.

Thank you.
Pavan

Rachit said...

Hi Vikram,

I tried this for a dynamic VO which was returning multiple rows. The code didnot work at the point where you have written rows[i].getAttribute("SelectFlag");
It gives an error getAttribute not found.
Please note that I am doing this coding in the CO.

Here is a snipet of the code that I have used.
public void processRequest(pageContext,webBean){
super.processRequest(pageContext,webBean);
String queryStatement = "Some Query";
OAApplicationModule am = pageContext.getRootApplicationModule();
OADBTransaction oadbtrans = (OADBTransaction)am.getOADBTransaction();
OAViewDef viewDef = oadbtrans.createViewDef();
viewDef.setSql(queryStatement);
OAApplicationModuleImpl amImpl = (OAApplicationModuleImpl)am;
OAViewObject viewObject = (OAViewObject)am.findViewObject("SomeViewObject");
if(viewObject == null){
viewObject = (OAViewObject)amImpl.createViewObject("XXTCGPersonInfoVO",viewDef);
}
if(viewObject!=null){
viewObject.executeQuery();
int fetchedRowCount = viewObject.getFetchedRowCount();
if (fetchedRowCount > 0)
{
// Save the original range size and range start.
savedRangeSize = viewObject.getRangeSize();
savedRangeStart = viewObject.getRangeStart();
/* Alter the range size and start in this order to
prevent any accidental row fault-in from the
database. */
viewObject.setRangeStart(0);
viewObject.setRangeSize(fetchedRowCount);
Row[] rows = (Row[])viewObject.getAllRowsInRange();
for (int i = 0; i < fetchedRowCount; i++)
{
if(rows[i]!=null && "Y".equals(rows[i].getAttribute("SelectFlag")))
{
/*operation to be performed on row*/
}
}
}
}

Vikram Kohli said...

Hi Rachit,

SelectFlag attribute is there in your view object. Check if attribute name in VO is same as of given in statement getAttribute("SelectFlag");

Vikram