You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Henrique Boregio <hb...@gmail.com> on 2011/03/10 04:25:12 UTC

RestartResponseAtInterceptPageException not redirecting to source Page

Hi, I have a RestartResponseAtInterceptPageException working correctly in
one case and not so in another.

I have a Login page with a LoginForm. In this form's onSubmit method, right
after the user validation takes place, I have:

if(!continueToOriginalDestination()) {
    setResponsePage(Dashboard.class);
}

When this is called form the following Page, it works correctly (the users
gets redirected to the Login page, and once he logs in correctly, he is
redirected back to the page below):
public class PublishItem {
public PublishItem() {
if(!UserLoggedInSession.get().isLoggedIn()) {
UserLoggedInSession.get().getFeedbackMessages().add(getPage(), "You need to
Sign in before you can publish!", FeedbackMessage.INFO);
throw new RestartResponseAtInterceptPageException(Login.class);
}
}
}

However, when this same logics is applied from within a Link's onClick
method, it does not work:
AnotherPage.java
Link signinLink = new Link("siginLink") {
public void onClick() {
UserLoggedInSession.get().getFeedbackMessages().add(getPage(), "Signin
before adding a comment!", FeedbackMessage.INFO);
            throw new RestartResponseAtInterceptPageException(Login.class);
}
};
signinLink.setVisible(!userLoggedIn);
add(signinLink);

In this second case, the user does get redirected to the Login page, and
once the correct username/password combination is entered, he actually logs
into the system. The problem is that the Login page simply refreshes, and
does not get redirected back to AnotherPage.java

Any help is appreciated.
Thanks.

Re: RestartResponseAtInterceptPageException not redirecting to source Page

Posted by Maarten Billemont <lh...@gmail.com>.
On 10 Mar 2011, at 04:25, Henrique Boregio wrote:
> 
> Hi, I have a RestartResponseAtInterceptPageException working correctly in
> one case and not so in another.
> 
> I have a Login page with a LoginForm. In this form's onSubmit method, right
> after the user validation takes place, I have:
> 
> if(!continueToOriginalDestination()) {
>    setResponsePage(Dashboard.class);
> }

In what wicket method is this?

> 
> When this is called form the following Page, it works correctly (the users
> gets redirected to the Login page, and once he logs in correctly, he is
> redirected back to the page below):
> public class PublishItem {
> public PublishItem() {
> if(!UserLoggedInSession.get().isLoggedIn()) {
> UserLoggedInSession.get().getFeedbackMessages().add(getPage(), "You need to
> Sign in before you can publish!", FeedbackMessage.INFO);
> throw new RestartResponseAtInterceptPageException(Login.class);
> }
> }
> }

getPage().info("You need to Sign in ..");

Also, you should probably do this check in an onBeforeRender, not in a constructor.

> 
> However, when this same logics is applied from within a Link's onClick
> method, it does not work:
> AnotherPage.java
> Link signinLink = new Link("siginLink") {
> public void onClick() {
> UserLoggedInSession.get().getFeedbackMessages().add(getPage(), "Signin
> before adding a comment!", FeedbackMessage.INFO);
>            throw new RestartResponseAtInterceptPageException(Login.class);
> }
> };
> signinLink.setVisible(!userLoggedIn);
> add(signinLink);

Your Link should override onConfigure and in there you should setVisible(!userLoggedIn) instead of only performing this check on page construction.

> 
> In this second case, the user does get redirected to the Login page, and
> once the correct username/password combination is entered, he actually logs
> into the system. The problem is that the Login page simply refreshes, and
> does not get redirected back to AnotherPage.java

But none of those tips likely have anything to do with what you're saying the problem is.  I suggest you attach a debugger on the point where you complete log-in and see what flow wicket follows and where it deviates from what you expect it to do.

> 
> Any help is appreciated.
> Thanks.



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