Hello. I just finished reading Wicket In Action, and now I'm working
on my first Wicket app. I have a simple question about page
redirects.
My application's homepage is WelcomePage.java, which I have mounted on
/welcome. However, if the user has already authenticated and they
have a session, I would like to immediately send them to HomePage.java
if they happen to browse to /welcome. HomePage.java is a "protected"
page that contains stuff only a logged user can see. Whereas
WelcomePage.java is the unauthenticated user's restricted view of the
site.
As a first step, I have chosen to implement this redirect in the
WelcomePage ctor as follows:
public WelcomePage(PageParameters parameters) {
add(new Label("message", "blah"));
if (AppSession.get().isAuthenticated()) {
setResponsePage(HomePage.class);
}
}
While checking the session for an authenticated user and setting the
response page to HomePage.class seems to work, I don't know if it
represents the "Wicket Way". I was thinking there may be a more
elegant way to affect the redirect, perhaps with one of the Page
lifecycle methods.
Would someone who has been here be kind enough to comment?
Thank you.
--
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]