I am trying to initialize a backing bean on page load. Already looked for many solutions, but most of them are using links,buttons or not having parameters at all.
scenario:
A customer logins to a site and then should see all of his data on the following page.
backing beans:
-
loginDetailsController – to support
login process. Can access user’s
password and username. Backing bean
for Login.xhtml. -
customerController – to access the
rest of user details. It also has a customer_id field. It is the Backing bean
for Home.xhtml. It is possible to initialize customerController entirely from customer_id.
On Home.xhtml it is possible to get customer_id this way:
#{loginDetailsController.customer_id}
Is there a way to initialize customerController with the above value on page load?
Regards,
Daniel
This is how I solved it:
Because LoginDetailsController is session scoped – customer_id is always initialized.
So – I added
Plus – getter and setter for customer_id.
On LoginDetailsController, as Nikhil said – with a little change.
Then, it is possible to use
#{customerController.customer_id}and the rest of customerController initialized elements of customerController on Home.xhtml.Thank you all!