On 4/19/07, ZedroS Schwart <[EMAIL PROTECTED]> wrote: > Hi Johan > > I still don't manage to do redirection from my code. > > I've even tried to do some redirection to other website or the base > URL of my app without success. > > The code I use is the following : > package purgat.web.pages.user; > > import org.apache.wicket.PageParameters; > import org.apache.wicket.ajax.AbstractAjaxTimerBehavior; > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.markup.html.link.BookmarkablePageLink; > import org.apache.wicket.markup.html.pages.RedirectPage; > import org.apache.wicket.util.time.Duration; > > import purgat.web.PurgatSession; > import purgat.web.SecuredBasePage; > import purgat.web.pages.base.IntroPage; > > public class LogoutPage extends SecuredBasePage { > public LogoutPage() { > super(); > // Setting of the session's user to null to indicate the user > isn't log > // in anymore > ((PurgatSession) getSession()).setUser(null); > BookmarkablePageLink manualLink = new > BookmarkablePageLink("linkTest", > IntroPage.class); > add(manualLink); > > add(new AbstractAjaxTimerBehavior(Duration.seconds(5)) { > protected void onTimer(AjaxRequestTarget target) { > setRedirect(true); > > // setResponsePage(new > RedirectPage("http://www.google.com")); > > getResponse().redirect("http://www.google.com"); > } > }); > } > } > > Instead of http://www.google.com I tried with the base URL of my app. > I'm using wicket 1.3 latest snapshot. > > What's wrong with my code ??
You can't use an ajax timer directly on page I think. There's a thread about it this week. This is the logout page we're using for the project I'm working on: public class LogOutPage extends WebPage { public LogOutPage() { setResponsePage(LoginPage.class); ((WebSession) getSession()).invalidate(); } } setResponsePage could be anything you want, like a redirect page, or you could call RequestCycle.get().setRequestTarget() with e.g. an instance of RedirectRequestTarget. Not sure how well this works in 1.2 though. Eelco ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user