I have a simple Panel that we call the QuickLogInPanel. This is a panel located in a 'side bar'. When the user is not logged in the panel shows a simple username/password form. After logging in I want to show just some text and a log out button.
So I did this: public class QuickLogInPanel extends Panel { public QuickLogInPanel(String string) { super(string); MySession session = (MySession) getSession(); if (session.getUser() == null) { add(new LogInForm("logInForm", new CompoundPropertyModel(new LogInCommand()))); } else { add(new PageLink("logOutLink", LogOutPage.class)); } } public String getVariation() { MySession session = (MySession) getSession(); if (session.getUser() == null) { return "LoggedOut"; } else { return "LoggedIn"; } } class LogInCommand { private String login; public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } class LogInForm extends Form { @SpringBean private LogInFacade logInFacade; public LogInForm(String id, IModel model) { super(id, model); add(new TextField("login")); add(new PasswordTextField("password")); add(new PageLink("forgotPasswordLink", ForgotPasswordPage.class)); add(new PageLink("signUpLink", SignUpPage.class)); } protected void onSubmit() { LogInCommand logInCommand = (LogInCommand) getModelObject(); User user = logInFacade.login(logInCommand.getLogin(), logInCommand.getPassword()); if (user != null) { MySession session = (MySession) getSession(); session.setUser(user); setResponsePage(getApplication().getHomePage()); } } } } Together with two markup files: QuickLogInPanel_LoggedIn.html QuickLogInPanel_LoggedOut.html But this gives all sorts of problems during logging in and out. I get the following error when the user logs in and the page is rendered again: WicketMessage: Unable to find component with id 'logOutLink' in MarkupContainer this is probably because the Panel is already instantiated; the constructor is not run again of course. Is there a way to 'reset' the component or to mark it 'dirty' so that the parent page will create it again? The Logout action shows the same kind of behaviour. I know I can fix this by putting some logic in the owning page and use two different kinds of panels, but I think one panel that just figures out what to do by itself is more elegant. S. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user