5

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

Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101
Ggdw
  • 2,509
  • 5
  • 24
  • 22
  • 1
    I cannot say much about Wicket 1.5, but I've checked in 6.x and session is being created before any calls to getHomePage(), which is kind of logical. – divanov Nov 06 '12 at 08:38
  • you are right i change the version from 1.5.3 to 1.5.8 and its working now – Ggdw Nov 12 '12 at 16:32

0 Answers0