On Thu, Mar 10, 2011 at 12:36 PM, Jim Goodwin <sophin...@comcast.net> wrote:

> I'm a Wicket newbie, working my way through /Wicket in Action.
>
> /I don't understand redirection too clearly yet, but there is
> an example in the book which doesn't work right when I
> try it and I'd like to ask if the book example code makes
> sense to more experienced folks.
>
> Page 271 Listing 11.3 line 4: The onSubmit() method calls
> !continueToOriginalDestination().
>

continueToOriginalDestination() lets the user continue on to the place they
were going before being interrupted by the security mechanism if they aren't
logged in.  i.e:

user on home page
user clicks "restricted page" link
security strategy says "can't go there without being logged in as X",
redirects user to login page
user logs in, and continueToOriginalDestination() redirects to "restricted
page" (original dest) and returns true.

another example:
user clicks bookmarked link in a new tab in their browser to login page (or
goes to unrestricted home page and clicks link for login page)
user logs in, and continueToOriginalDestination() can't redirect them
anywhere, because there is no "original destination" that was interrupted

Page 272 Listing 11.4 , new Link(...){ ... method onClick():
> throws new RestartResponseAtInterceptPageException(signInPage)
>

This is a way to stop processing at ANY point in your application and
redirect the user to a certain page.


> How is this supposed to work?
>
> Suppose the user is on the Home page, and the Home Page
> has a UserPanel, and the user clicks on the "Sign In" link.
> Then  the link itself sets an intercept to the sign-in page
> (that is how the link arranges to take you there, as far as I can
> understand).
>
> But then, when the user enters name/password and submits, and
> the submit method  calls continueToOriginalDestination(), it will
> always succceed, and find the "original destination" to be the signIn
> page, regardless of where it really originated (the Home Page, in
> this case).
>

You're a bit confused by "original" and "destination".  Since the user
clicked the "signin page" link, the *destination* was the signin page -
which is unrestricted, so the continueToOriginalDestination() method can not
redirect them anywhere, and thus returns false.  You now need to redirect
them somewhere manually or the signin page will re-render.

The *origin* was the home page - but that doesn't matter.  Don't be thrown
off by "original" (destination) and "origin" - which are two different
things.  :)

For a while my code was working like that: Signing in worked,
> i.e. it did sign you in, but you were returned to a blank sign-in page.
> (My code doesn't work like that just this minute, but that is only
> because I've been enhancing it with other bugs.)
>
> Can anyone explain how the book-example is supposed to work?
>
> Thanks
> Jim
>


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Reply via email to