You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by peakmop <pe...@yahoo.com> on 2011/11/23 23:57:55 UTC

Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

In MyAuthorizationStrategy that implements IAuthorizationStrategy I throw
RestartResponseAtInterceptPageException( LoginPage.class ) if the user is
not logged in and requests a bookmarkable page.
In the LoginPage onSubmit() the call is made: 
      if ( !continueToOriginalDestination() )
      {
        setResponsePage( getApplication().getHomePage() );
      }
      
      return;

The call to  continueToOriginalDestination always throws
ReplaceHandlerException and never gets to the 'return' part because it seems
that there is still an active RequestHandler in the RequestHandlerStack.
Do I need to explicitly handle this exception and detach() the current
RequestHandler to let the next scheduled handler execute (and redirect to
the bookmarkable page request), or do I prevent the exception from occuring
somehow (since there wasn't one thrown in wicket 1.4.x)?


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4101981.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by pricarvalho <pr...@gmail.com>.
Hi, Martin.

"First, sorry for any mistakes, but I am Brazilian and my English is not
very good." :-)

I need your help. I found exactly the same problems you, as follows:

*
// This page will be redirect to a page intercepting
public class Checkout extends WebPage {
      User loggedInUser = session.getLoggedInUser();
		
               if (loggedInUser == null) {
			redirectToInterceptPage(new Login(params));
		}
}

public class Login extends WebPage {

            // Method should return true and display the Checkout page
                if (!this.continueToOriginalDestination()) {
			setResponsePage(ShowCatalog.class);
		}
}
*
Results: The method does not return true and throws the exception
ReplaceHandlerException, not redirecting after login to the Checkout page. I
don't know how to deal it. 

How did you solve this problem?


peakmop wrote
> 
> To follow up, and to put this issue at rest, here's the explanation
> (thanks to the wicket authentication examples):
> The ReplaceHandlerException will get thrown if there is an active request
> handler on the stack to stop its execution and start executing the new
> request handler (usually RedirectRequestHandler) if the original request
> was for some bookmarkable page. The exception eventually will get
> intercepted in the request handler code and the new request handler will
> get executed, and the requested page will eventually be rendered. Since
> before WICKET-4269 addressed the return values of
> continueToOriginalDestination(), that method return values were used to
> determine whether a redirect to the default (usually home page) or a
> redirect to the requested page is to take place. I was catching an
> Exception in the login page which also intercepted the
> ReplaceHandlerException which prevented the replacement request handler
> from being successfully executed down the road. I didn't realize this
> until I attached a debugger to the authentication examples.
> Developers can correct me if I'm off in my explanation here.
> 
> -Martin-
> 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4649528.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by peakmop <pe...@yahoo.com>.
To follow up, and to put this issue at rest, here's the explanation (thanks
to the wicket authentication examples):
The ReplaceHandlerException will get thrown if there is an active request
handler on the stack to stop its execution and start executing the new
request handler (usually RedirectRequestHandler) if the original request was
for some bookmarkable page. The exception eventually will get intercepted in
the request handler code and the new request handler will get executed, and
the requested page will eventually be rendered. Since before WICKET-4269
addressed the return values of continueToOriginalDestination(), that method
return values were used to determine whether a redirect to the default
(usually home page) or a redirect to the requested page is to take place. I
was catching an Exception in the login page which also intercepted the
ReplaceHandlerException which prevented the replacement request handler from
being successfully executed down the road. I didn't realize this until I
attached a debugger to the authentication examples.
Developers can correct me if I'm off in my explanation here.

-Martin-


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4123670.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by Igor Vaynberg <ig...@gmail.com>.
https://issues.apache.org/jira/browse/WICKET-4269

-igor

On Mon, Nov 28, 2011 at 6:47 AM, peakmop <pe...@yahoo.com> wrote:
> Tor Iver is correct, in 1.4.x the call to continueToOriginalDestination
> didn't throw an exception but rather a boolean result. While in 1.5.x it
> still returns a boolean result, but it does so if
> replaceAllRequestHandlers() call returns without throwing an exception.
> My question is twofold: is there something that can be done to prevent an
> exception and receive a boolean response from the call, or if the exception
> is expected (which makes the boolean logic irrelevant), how to handle it
> most appropriately so the next request handler is executed (which is what
> replaceAllRequestHandlers() is intended to perform in the first place)?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4115437.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by peakmop <pe...@yahoo.com>.
Tor Iver is correct, in 1.4.x the call to continueToOriginalDestination
didn't throw an exception but rather a boolean result. While in 1.5.x it
still returns a boolean result, but it does so if
replaceAllRequestHandlers() call returns without throwing an exception.
My question is twofold: is there something that can be done to prevent an
exception and receive a boolean response from the call, or if the exception
is expected (which makes the boolean logic irrelevant), how to handle it
most appropriately so the next request handler is executed (which is what
replaceAllRequestHandlers() is intended to perform in the first place)?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4115437.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Nov 24, 2011 at 10:43 AM, Wilhelmsen Tor Iver
<To...@arrive.no> wrote:
>> continueToOriginalDestination() does alway sthrow the replacehandler
>> exception. this is how that method works...
>
> In 1.5 perhaps, in 1.4 it returns false if it was not a redirect; that might be the cause of confusion.

The behavior is the same as in 1.4.x

>
> - Tor Iver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> continueToOriginalDestination() does alway sthrow the replacehandler
> exception. this is how that method works...

In 1.5 perhaps, in 1.4 it returns false if it was not a redirect; that might be the cause of confusion.

- Tor Iver

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handling ReplaceHandlerException on continueToOriginalDestination in wicket 1.5

Posted by Igor Vaynberg <ig...@gmail.com>.
dont really understand what you mean...

continueToOriginalDestination() does alway sthrow the replacehandler
exception. this is how that method works...

why is it a problem/why are you trying to deal with the new handler?

-igor

On Wed, Nov 23, 2011 at 2:57 PM, peakmop <pe...@yahoo.com> wrote:
> In MyAuthorizationStrategy that implements IAuthorizationStrategy I throw
> RestartResponseAtInterceptPageException( LoginPage.class ) if the user is
> not logged in and requests a bookmarkable page.
> In the LoginPage onSubmit() the call is made:
>      if ( !continueToOriginalDestination() )
>      {
>        setResponsePage( getApplication().getHomePage() );
>      }
>
>      return;
>
> The call to  continueToOriginalDestination always throws
> ReplaceHandlerException and never gets to the 'return' part because it seems
> that there is still an active RequestHandler in the RequestHandlerStack.
> Do I need to explicitly handle this exception and detach() the current
> RequestHandler to let the next scheduled handler execute (and redirect to
> the bookmarkable page request), or do I prevent the exception from occuring
> somehow (since there wasn't one thrown in wicket 1.4.x)?
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Handling-ReplaceHandlerException-on-continueToOriginalDestination-in-wicket-1-5-tp4101981p4101981.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org