I haven't read it in detail, but variation is not meant for doing that kind of stuff (though it should work). Rather, use panels and replacement (switch the panels).
Eelco On 8/2/06, Juergen Donnerstag <[EMAIL PROTECTED]> wrote: > I guess it is because Wicket caches the Markup associated with a > Component. Wicket assumes that the associated Markup does not change > once loaded, except if you change the markup file content itself, > because the cache will be cleared than. I guess I would create two > separate Panels for LoggedIn and LoggedOut and either add() the one or > the other to the container. > > Juergen > > On 8/2/06, Stefan Arentz <[EMAIL PROTECTED]> wrote: > > 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 > > > > ------------------------------------------------------------------------- > 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 > ------------------------------------------------------------------------- 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