I think this is a jsf basic question but I simply require a little bit of explanation..
I have a login page where I have a link to a CreateAccount page:
<div
id="TGOV_popAccount"
style="float: left; margin-left: 60px !important;"><a
href="/createAccount.jsp">Create Account</a></div>
Now, this jsp page open a jsf facelet one (yeah, ugly design):
createAccount.jsp:
<jsp:forward page="/WEB-INF/jsf/account/createAccount.jsf" />
so now, this createAccount.jsf has a CreateAccountBean as the backing bean with request scope. The first time I go to create account page the constructor calles the init method (for some reason the @PostConstruct is not automatically called, that’s why I call it from constructor…maybe because of that jsp forward?)
public CreateAccountBean() {
init();
}
@PostConstruct
public void init() {
userLoginVo = new UserLoginVo();
logger.info("init called");
}
If a open again my login page and go again to createAccount page, the init is no longer called and I do not understand why… Having a request scope, it should be reinitialized in this situation, right?
Can you explain me why it fails?
Thanks.
Get your JSF out of
/WEB-INFand link to it immediately.As to the initialization failure, likely the page is been served from the browser cache instead of from the server. Create a
Filterwhich is mapped on<servlet-name>facesServlet</servlet-name>and does the following job in thedoFilter()method: