Wednesday, April 7, 2010

Adding programmatic fire Action to UIX beans which dont support it

Recently, a friend had a requirement of a customization in a seeded page where he needs to put some validation on a table column which was actually OAMessageDateFieldBean.

This is quite simple and generic requirement , when he called me ...I told him that since , this has to be done in seeded Oracle page and fire action elements can't be added by personalization,he just needs to extend the CO and attach fire action programatically to the OAMessageDateFieldBean in process request and then can handle his logic of validation in process form request.But the tricky part came when he told me his code is not compiling since setFireActionForSubmit API is absent in OAMessageDateFieldBean class.

I just wondered how is it possible since this bean allows me to configure fireaction decalaratively, then there should be an API of doing it programatically too in the bean. Then I remebered with each UIX bean Oracle also gives a helper class, which can usually be instantiated by using getHelper(), on the bean instance.

Whenever you are in such situations , its worth while to look into bean helper classes. Ok.. so here is the code how you can configure firection on OAMessageDateFieldBean programatically :

//In process request.

//getting table bean instance
OATableBean t=(OATableBean)webBean.findChildRecursive("< table bean id >");

//getting OAMessageDateFieldBean inside
//table bean
OAMessageDateFieldBean expDate = (OAMessageDateFieldBean)t.findChildRecursive("< OAMessageDateFieldBean id >");

//hard-parameters for fire action
//it will help us to identify if action
//has occured or not
Hashtable params = new Hashtable (1);
params.put ("XX_ACTION","XXX");

//bound value parameters for fire action
// basically the primary key attribute of
//VO to get the row from which action has occured
//eg, lets say the VO attribute is Visit id AND
//that is primary key
Hashtable paramsWithBinds = new Hashtable(1);
paramsWithBinds.put ("XX_PRIMARY",new OADataBoundValueFireActionURL((OAWebBeanData) expDate, "{$VisitId}"));

//Most important---
//taking helper class instance
// there we get the API to attach fire action.
expDate.getHelper().setFireActionForSubmit(expDate,"delete",params, paramsWithBinds,false,false);

//In Process form request

if(pageContext.getParameter("XX_ACTION")!=null)
{
//by this primary key we can retrieve the VO row at which
// action occured and utilise the other column data
// for validations.
String primary_key=pageContext.getParameter("XX_PRIMARY");

.......

//finally releasing the parameters from
//current pagecontext requesr
pagecontext.removeParameter("XX_ACTION");
pagecontext.removeParameter("XX_PRIMARY");
}



Alternative : There is a alternate way to attach PPR/Fireaction to any bean.Use static methods in class OAWebBeanUtils, like
OAWebBeanUtils.getFirePartialActionForSubmit()
OAWebBeanUtils.getFireActionForSubmit()
and then use

// finally set it on your bean
bean.setAttributeValue
(PRIMARY_CLIENT_ACTION_ATTR, fireAction);

Happy coding....!

10 comments:

RajashekharReddy said...

How to show progress bar in oa framework

Mukul Gupta said...

Rajashekar as of now there is no support for progress support in OAF, instead you can use OAProcessing Page, refer to dev guide for details.
--Mukul

John said...

really nice blog and thanks for sharing.
- Web Development Company

Daniel Longmore said...

All good. Is it also possible to trigger the event from processRequest. Simulating the button being pressed, as if a person pressed the button.

sridhar tylam said...

Hi Mukul,
It is good but I got similar requirement when I am trying like this I am unable to compile it is showing error in
expDate.getHelper().setFireActionForSubmit(expDate,"delete",params, paramsWithBinds,false,false); is
expects “oracle.apps.fnd.framework.webui.beans.OAWebBean ” Not OAMessageDateFieldBean Error is showing for first parameter.
Please provide me solution for this.

Thanks in advance,
Sridhar.

Megha said...

Hi Mukul,

I have implemented similar piece of code bt i am not able to read the hashmap values i PFR :(.. Pls help...!!!

Shravan Kumar said...
This comment has been removed by the author.
Shravan Kumar said...
This comment has been removed by the author.
Shravan Kumar said...

Hi Mukul,

There is seeded OA page where I need to customize the page for the following requirement: THere are two message choice fields, where I need tomake the second message choice values dynamic based on the value chosen in first field. There is no PPR assoacited with first message choice in seeded page.How can I do this? came to know can be done through Java scripting...is it recommended?please advise.

Satvik said...

Very Good blog.
Use import java.util.Hashtable
if you are getting error for Hashtable parameters in setFireActionForSubmit