I am building a web application using Wicket 1.5. I need to decide if the user that is currently logged in is an admin or a regular user and display different page for each of them.
My code:
public class HomePage extends WebApplication {
private boolean flag = false;
@Override
protected void init(){do things}
@Override
public Session newSession(Request request, Response response) {
... some calculation ...
return new HomePageWebSession(request);
}
@Override
public Class<? extends WebPage> getHomePage(){
if(flag){
return Admin.class
} else return User.class
}
}
The problem is that getHomepage
is called before newSession
and I use newSession to figure out if the user is Admin or not and init the flag.
In addition I see that getHomePage
is called multiple times before newSession
is called.
Why is getHomePage
called multiples times and why is getHomePage
called before newSession
?
thanks for any help