Thursday, 17 February 2011

Executing Particular Method Before Page Loads


Sometimes It is needed to Execute Some methods before page loads or component loads.

These can be done in many ways like:

1> Using an ADF/JSF Page Phase Listener (oracle.adf.controller.v2.lifecycle.PagePhaseListener/javax.faces.event.PhaseListener)

2> Using a page backing bean superclass which provides an onLoad( ) method

3> Using a custom Page Controller (oracle.adf.controller.v2.lifecycle.PageController)

4> Using managed bean for page 

5> Using Page Def for particular page

6> Using Task Flow 

and may be many more .. :) 

First start with simplest one : Using managed bean 

First Create one Test Fusion Application then create the testPage.jspx

I have created the backing bean (managed bean) at page creation time to save time for creating bindings needed. It does not matter if create managed bean and do not expose all the page components.



I have written my test method which should be executed before components load. 

 I want that the method should be executed before document loads and form loads.

So I have called the method in both the components getter method.




Now if we run the page it will be executed before the document and form loads.





I will be updating the other ways also in my blog  in future.
There may be specific scenarios where other ways should be followed (like: even before the page is hit some methods should be executed).

Please comment for queries. 

4 comments:

  1. what about the other methods?
    greetings from Chile

    ReplyDelete
  2. Thanks. Can you please provide source code for examples.

    ReplyDelete
  3. Great article. Is there any updates on the other method examples? Also, any chance we could get the sample code. I have a similar use case where I want to set my form fields as read-only depending on a View Object value before page load. Thanks.

    ReplyDelete
  4. please re-upload photos of the description of your post

    ReplyDelete