Go to Google Groups Home    ADF Enterprise Methodology Group
Re: [ADF Enterprise Methodology Group] Re: pattern for run a method on start of the page only 1 time

Avrom Roy-Faderman <av...@avromroyfaderman.com>

For a VO method, I think a bind variable (to hold a "this method's already
been executed" flag) is probably the best way to do this. For a view row
method, use a transient attribute (make sure it's marked for
passivation--see below). For an application module method, you could try
setting a value on the Map returned by
ApplicationModuleImpl.getSession().getUserData().

One thing you *don't* want to do is just make a field and store your flag
in that, unless you're willing to override methods like
prepareForPassivation() and activateState(). If you just use an ordinary
Java field, the value could disappear if the application module gets
recycled.

Best,
Avrom

> That's a great question ; Frank;

>      Earlier this week ,

>        I posted this
> thread<http://forums.oracle.com/forums/message.jspa?messageID=3586332#3586332>at
> otn jDev's forum too; but no cookies for me !

>        As i describe there, to work around this "so many call's" I; early
> check if my viewObjects parameter are set  and if the value is equal my
> current params;

>        So depending on the target viewObject's parameters; I set or not
> and
>  re-execute the viewObject;

>      Other behavior that I would like to insert here, is how we can
> coordnate the execution of onChangeEvent (from any faces component) and
> onLoadPage ( or prepareModel ) phase;

>      if we log this two methods we will have;

>         on Log window;

>               Hi there ... from prepareModel (loadPage)
>               Hi there ... from onChangeEvent
>               Hi there ... from prepareModel (loadPage)

>     Do we have some "best pratices" for this ??

>     Or perhaps i'm missunderestanding something ....

> Thanks too;

>       Marcos Ortega
>  Analista de Sistemas
>   Campo Grande - MS
> http://www.santoandrea.com.br

> 2009/7/1 akhanof <amir.kha...@gmail.com>

>> Hi,

>> Regarding to invoke a method in the page start up and only one time I
>> am looking for the best pattern to use;
>> because using the (refresh condition= not post back) is some times
>> invoked more than one time making it inappropriate when we absolutely
>> need to run the method only 1 time .
>> is there any other option or pattern except setting the refresh
>> condition="#{!adfFacesContext.postback}" for execution of the method
>> on the invokeaction for method on the page bindings.

>> Thanks and regards,
>> Amir

--
Avrom’s Java EE and Oracle ADF Blog
http://www.avromroyfaderman.com