I've found that the easiest thing to do is just remember the url that your user was trying to load in the first place. In my base page I have this:
@InjectPage private Login _loginPage; public Object onActivate(Object[] context) { // Only let the request through if the user has logged in if (!_loginStateExists || !_loginState.isValid()) { _loginState = null; final Link link = _linkSource.createPageRenderLinkWithContext(_resources.getPageName(), context); _loginPage.setSuccessLink(link); return _loginPage; } return null; } Then when the form is submitted to the login page I have this: /** * Where to go after a successful login. */ @Persist private Link _successLink; Object onSuccess() { if (_successLink != null) { final Link link = _successLink; _successLink = null; // we only use the link once. return link; } return Index.class; // no link set, just go to home page. } Josh 2009/8/9 Vjeran Marcinko <vjeran.marci...@email.t-com.hr> > I know that onActivate can have EventContext argument, but it's less > explicit compared to some specific onActivate for given page, such as > > public void onActivate(Long id) {...} > > and I don't want every page to have : > public void onActivate(EventContext ec) {...} > > just because I want each of those pages to be accessed in a generic way > from LoginPage when user logs in. > > What I need is some generic way of collectiing activation context values > from some page instance (eg. triggering "passivate" event on page instance > and collecting return values), and also applying that same activation > context on desired page instance also in generic fashion (triggering > "activate" event with that argument). > > I cannot do any of this via spoecific hardcoded way, since maybe some of my > page has activation context specified via @PageActivationContext so I don't > have an option to call manually onActivate or onPassivate, I have to di it > the same way as Tapestry is doing it internally when it manages activation > context. > > -Vjeran > > ----- Original Message ----- From: "Felix Gonschorek" <fe...@ggmedia.net> > To: "Tapestry users" <users@tapestry.apache.org> > Sent: Sunday, August 09, 2009 1:48 PM > Subject: Re: [T5] Log in directly to requested page (not just home page) > > > > Hi, >> >> there are two hints that may help you: >> >> You have two additional options for the parameters of you onActivate() >> method: >> >> a) One parameter of type Object[] >> b) One parameter of type EventContext >> ( >> http://tapestry.apache.org/tapestry5/apidocs//org/apache/tapestry5/EventContext.html >> ) >> >> i use b) very often >> >> felix >> >> >> >> Vjeran Marcinko schrieb: >> >>> Hello, >>> >>> Is there any way to genericaly extract activation context (array or >>> EventContext) from some page instance? >>> >>> I'm asking this because I want my page authorization to work in a way to >>> remember what page and activation context has been requested by >>> unauthorized user, so that after he logs in successfuly, I would >>> redirect him to that requested page. For that to work, inside my >>> SecuredPage superclass, I have to be able to extract requested page name >>> (which is easy) and also activation context (which I don't know how), so >>> I would be able to store them inside LogIn page form for later access in >>> case of successful login. >>> >>> BTW, is there also some generic way to apply activation context on page >>> instance without calling onActivate insid ecode, because I would >>> probably have something like: >>> >>> public void onActivate(Long id) {...} >>> >>> whereas I have activation in a array form? >>> >>> Or some other suggestion for implementing this feature maybe? I guess >>> this functionality would also be useful for implementing some generic >>> breadcrumbs component.... >>> >>> Regards, >>> Vjeran >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > > -------------------------------------------------------------------------------- > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.392 / Virus Database: 270.13.48/2292 - Release Date: 08/09/09 > 08:08:00 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.