beans? , @PostConstruct
bean.
@ManagedBean
@ViewScoped
public class LoginDetailsController() {
private String customer_id;
@PostConstruct
public void init() {
this.customer_id = fetch_the_value_from_somewhere;
}
}
If you want your page to always execute this method, whether the bean is created or not, use PreRenderViewEventTarun as suggested correctly. But be careful that this event is fired every time a page is displayed; even when the user refreshes the page.
If you want to use this value from LoginDetailsControllerin customerController, you can enter it as follows
@ManagedBean
@ViewScoped
public class CustomerController() {
@ManagedProperty(value="#{loginDetailsController}")
private LoginDetailsController loginDetailsController;
private String customer_id;
@PostConstruct
public void init() {
this.customer_id = loginDetailsController.getCustomer_id();
}
source
share