I want to know how to call a method in the backing bean once the page loads..
Consider this scenerio
Once the user login is successfull his details are shown in the welcome page.
Say I have login.xhtml and welcome.xhtml
I have managed beans LoginController and DetailsController,Both are in SessionScope
There is a method called getDetails() in DetailsController
calling the method from the constructor would not be recommended method since I have read from DB in getDetails()
How do I call it on when the user is being redirect to welcome.xhtml where once he s redirected he should be able to see his details..
Thanks:)
Check out the events e.g. you can have a preRenderView event which calls a backing bean method when the view is rendered:
Then get the data you want in scope via the preRender method on your bean. Typically this method would read data from a database and set in an appropriate scope e.g. View Scope. Your Value Bindings e.g. on outputText or inputText components would then just bind to the Objects you created or modified via the preRenderView event.