You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nishant Neeraj <ni...@gmail.com> on 2010/03/13 13:06:01 UTC

Using SetResponsePage in Session

Hi,

In my custom session, I have a method which, on certain condition, wants to
redirect the request to some page, other than the original.
This is what I am doing, in the method:

RequestCycle.get().setRedirect(true);
RequestCycle.get().setResponsePage(SomePage.class);

But the response continues to land on the originally requested page
requested page.

Is there any way to do this without invalidating the session?

Thanks
Nishant

Re: Using SetResponsePage in Session

Posted by Nishant Neeraj <ni...@gmail.com>.
Right. Thanks.
So, I am doing this check in my custom base page (which is extended by all
others).
I am able to redirect user to "switch accounts" page.

My initial understanding was that Session.replaceSession() or
Session.invalidateNow() + Session.bind() will reset the current session and
hence all the objects in current session. but unfortunately, it does not.

Right now, I want to start a new session on an button onClick. I'm wondering
if it's possible.
Any clue?

Thanks
- Nishant

On Sun, Mar 14, 2010 at 1:37 AM, Edward Zarecor <ed...@indeterminate.org>wrote:

> I would check if the user already exists in the session, but send the
> redirect from a Page.  You can refactor the redirection code into a base
> class and extend as required.
>
> Ed.
>
> On Mar 13, 2010 2:04 PM, "Nishant Neeraj" <
> nishant.has.a.question@gmail.com>
> wrote:
>
> The use case is like this.
>
> You have logged-in in a browser's tab and in another tab, you click on a
> moderate-comment mail that automatically logs you in as another user, and
> takes you to the comments-moderation page of the application.
>
> Now, at this point, I want to ask the user if he wants to switch account.
> [The way Google does if you are signing-in in two tabs as different users]
>
> So, instead of comment-moderation page, I want to take user to "Do want to
> switch account?" page (if another user is already logged-in in another
> tab).
> Depending on the users decision I will either invalidate the old session
> and
> log-in as new user or will just take the user to already logged in
> session's
> home page.
>
> The thing is, I wanted to do this all the time. Whenever I am calling
> MySession.get().setUser(UserVO uvo), I want to check if there already
> exists
> a different userVO in the same session. If so, the end user must be
> notified.
>
> Thanks
> Nishant
>
> On Sat, Mar 13, 2010 at 7:24 PM, Edward Zarecor <edward@indeterminate.org
> >wrote:
>
>
> > What's the use case? Session events won't always occur within the
> > context of a RequestCycle, s...
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Using SetResponsePage in Session

Posted by Edward Zarecor <ed...@indeterminate.org>.
I would check if the user already exists in the session, but send the
redirect from a Page.  You can refactor the redirection code into a base
class and extend as required.

Ed.

On Mar 13, 2010 2:04 PM, "Nishant Neeraj" <ni...@gmail.com>
wrote:

The use case is like this.

You have logged-in in a browser's tab and in another tab, you click on a
moderate-comment mail that automatically logs you in as another user, and
takes you to the comments-moderation page of the application.

Now, at this point, I want to ask the user if he wants to switch account.
[The way Google does if you are signing-in in two tabs as different users]

So, instead of comment-moderation page, I want to take user to "Do want to
switch account?" page (if another user is already logged-in in another tab).
Depending on the users decision I will either invalidate the old session and
log-in as new user or will just take the user to already logged in session's
home page.

The thing is, I wanted to do this all the time. Whenever I am calling
MySession.get().setUser(UserVO uvo), I want to check if there already exists
a different userVO in the same session. If so, the end user must be
notified.

Thanks
Nishant

On Sat, Mar 13, 2010 at 7:24 PM, Edward Zarecor <edward@indeterminate.org
>wrote:


> What's the use case? Session events won't always occur within the
> context of a RequestCycle, s...
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Using SetResponsePage in Session

Posted by Nishant Neeraj <ni...@gmail.com>.
The use case is like this.

You have logged-in in a browser's tab and in another tab, you click on a
moderate-comment mail that automatically logs you in as another user, and
takes you to the comments-moderation page of the application.

Now, at this point, I want to ask the user if he wants to switch account.
[The way Google does if you are signing-in in two tabs as different users]

So, instead of comment-moderation page, I want to take user to "Do want to
switch account?" page (if another user is already logged-in in another tab).
Depending on the users decision I will either invalidate the old session and
log-in as new user or will just take the user to already logged in session's
home page.

The thing is, I wanted to do this all the time. Whenever I am calling
MySession.get().setUser(UserVO uvo), I want to check if there already exists
a different userVO in the same session. If so, the end user must be
notified.

Thanks
Nishant

On Sat, Mar 13, 2010 at 7:24 PM, Edward Zarecor <ed...@indeterminate.org>wrote:

> What's the use case?  Session events won't always occur within the
> context of a RequestCycle, say, expiry.
>
> Even If the use case is related to a request something like this might
> be cleaner:
>
> YourPage
>
>      if (getYourApp().getYourSession().isWhatever())
>       {
>      RequestCycle.get().setRedirect(true);
>      RequestCycle.get().setResponsePage(SomePage.class);
>       } else { ....
>
> Ed.
>
> On Sat, Mar 13, 2010 at 7:06 AM, Nishant Neeraj
> <ni...@gmail.com> wrote:
> > Hi,
> >
> > In my custom session, I have a method which, on certain condition, wants
> to
> > redirect the request to some page, other than the original.
> > This is what I am doing, in the method:
> >
> > RequestCycle.get().setRedirect(true);
> > RequestCycle.get().setResponsePage(SomePage.class);
> >
> > But the response continues to land on the originally requested page
> > requested page.
> >
> > Is there any way to do this without invalidating the session?
> >
> > Thanks
> > Nishant
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Using SetResponsePage in Session

Posted by Edward Zarecor <ed...@indeterminate.org>.
What's the use case?  Session events won't always occur within the
context of a RequestCycle, say, expiry.

Even If the use case is related to a request something like this might
be cleaner:

YourPage

      if (getYourApp().getYourSession().isWhatever())
      {
      RequestCycle.get().setRedirect(true);
      RequestCycle.get().setResponsePage(SomePage.class);
      } else { ....

Ed.

On Sat, Mar 13, 2010 at 7:06 AM, Nishant Neeraj
<ni...@gmail.com> wrote:
> Hi,
>
> In my custom session, I have a method which, on certain condition, wants to
> redirect the request to some page, other than the original.
> This is what I am doing, in the method:
>
> RequestCycle.get().setRedirect(true);
> RequestCycle.get().setResponsePage(SomePage.class);
>
> But the response continues to land on the originally requested page
> requested page.
>
> Is there any way to do this without invalidating the session?
>
> Thanks
> Nishant
>

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