You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Asenov <mA...@velti.com> on 2010/02/04 14:16:51 UTC

setResponsePage in the beggining of a constructor does not work

Hello guys!

I've got three pages, where I do certain check in the beginning and if the criteria is not met, I redirect to home page. I make it that way:

public MyPageClass {

            if (something) {
                        system.out.println("mypageclass - we're in");
                        setResponsePage(getApplication().getHomePage());
            }

.... page initialization afterwards
}

The strange thing is that it works for one of the pages, for another two - it does not - there is no redirection at all; it goes on with further initializing. The criteria check block is the very same one in each of the pages.

Appreciate if someone helps!

Regards,
Martin

RE: setResponsePage in the beggining of a constructor does not work

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
Cool, thanks! That works fine.

> Just write this in WebApplication#init:
> getApplicationSettings().setPageExpiredErrorPage(PageExpiredError.class);
> This should solve your problem.
> 
> Regards,
> Peter
> 
> 2010-02-05 00:59 keltezéssel, Chris Colman írta:
> > Could I use RestartResponseException to redirect to a URL instead of a
> bookmarkable page?
> >
> > My problem is that all of my pages require a parameter (even the home
> page but that's fine because the Tomcat container server.xml configures
> the appropriate redirection for me - users never have to enter the
> parameters in the address bar) but the "Expired Page" page contains a link
> that does not contain any parameters.
> >
> > When a session expires the page that appears attempts to go to the
> 'home' page without any parameters. If I could either change the expired
> page's link or do a redirect in the home page's constructor that
> redirect's to "/" then this would work fine.
> >
> > Unfortunately the RestartResponseException seems to only want to
> redirect to bookmarkable pages. Is there an alternative I could use to
> redirect to the "/" URL?
> >
> >> -----Original Message-----
> >> From: Martin Asenov [mailto:mAsenov@velti.com]
> >> Sent: Friday, 5 February 2010 12:30 AM
> >> To: users@wicket.apache.org
> >> Subject: RE: setResponsePage in the beggining of a constructor does not
> >> work
> >>
> >> Thanks friend! Works great! You saved me a lot of time!
> >>
> >> Best regards,
> >> Martin
> >>
> >> -----Original Message-----
> >> From: Major Péter [mailto:majorpetya@sch.bme.hu]
> >> Sent: Thursday, February 04, 2010 3:21 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: setResponsePage in the beggining of a constructor does not
> >> work
> >>
> >> Hi,
> >>
> >> the setresponsepage only marks, that the pagetarget is something else
> on
> >> the end of the cycle, but it isn't stopping the execution of the
> current
> >> page. If you want that, then use:
> >> throw new RestartResponseException(getApplication().getHomePage());
> >>
> >> Regards,
> >> Peter
> >>
> >> 2010-02-04 14:16 keltezéssel, Martin Asenov írta:
> >>> Hello guys!
> >>>
> >>> I've got three pages, where I do certain check in the beginning and if
> >> the criteria is not met, I redirect to home page. I make it that way:
> >>>
> >>> public MyPageClass {
> >>>
> >>>             if (something) {
> >>>                         system.out.println("mypageclass - we're in");
> >>>
> setResponsePage(getApplication().getHomePage());
> >>>             }
> >>>
> >>> .... page initialization afterwards
> >>> }
> >>>
> >>> The strange thing is that it works for one of the pages, for another
> two
> >> - it does not - there is no redirection at all; it goes on with further
> >> initializing. The criteria check block is the very same one in each of
> the
> >> pages.
> >>>
> >>> Appreciate if someone helps!
> >>>
> >>> Regards,
> >>> Martin
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
> >
> > ---------------------------------------------------------------------
> > 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


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


Re: setResponsePage in the beggining of a constructor does not work

Posted by Major Péter <ma...@sch.bme.hu>.
Just write this in WebApplication#init:
getApplicationSettings().setPageExpiredErrorPage(PageExpiredError.class);
This should solve your problem.

Regards,
Peter

2010-02-05 00:59 keltezéssel, Chris Colman írta:
> Could I use RestartResponseException to redirect to a URL instead of a bookmarkable page?
> 
> My problem is that all of my pages require a parameter (even the home page but that's fine because the Tomcat container server.xml configures the appropriate redirection for me - users never have to enter the parameters in the address bar) but the "Expired Page" page contains a link that does not contain any parameters.
> 
> When a session expires the page that appears attempts to go to the 'home' page without any parameters. If I could either change the expired page's link or do a redirect in the home page's constructor that redirect's to "/" then this would work fine.
> 
> Unfortunately the RestartResponseException seems to only want to redirect to bookmarkable pages. Is there an alternative I could use to redirect to the "/" URL?
> 
>> -----Original Message-----
>> From: Martin Asenov [mailto:mAsenov@velti.com]
>> Sent: Friday, 5 February 2010 12:30 AM
>> To: users@wicket.apache.org
>> Subject: RE: setResponsePage in the beggining of a constructor does not
>> work
>>
>> Thanks friend! Works great! You saved me a lot of time!
>>
>> Best regards,
>> Martin
>>
>> -----Original Message-----
>> From: Major Péter [mailto:majorpetya@sch.bme.hu]
>> Sent: Thursday, February 04, 2010 3:21 PM
>> To: users@wicket.apache.org
>> Subject: Re: setResponsePage in the beggining of a constructor does not
>> work
>>
>> Hi,
>>
>> the setresponsepage only marks, that the pagetarget is something else on
>> the end of the cycle, but it isn't stopping the execution of the current
>> page. If you want that, then use:
>> throw new RestartResponseException(getApplication().getHomePage());
>>
>> Regards,
>> Peter
>>
>> 2010-02-04 14:16 keltezéssel, Martin Asenov írta:
>>> Hello guys!
>>>
>>> I've got three pages, where I do certain check in the beginning and if
>> the criteria is not met, I redirect to home page. I make it that way:
>>>
>>> public MyPageClass {
>>>
>>>             if (something) {
>>>                         system.out.println("mypageclass - we're in");
>>>                         setResponsePage(getApplication().getHomePage());
>>>             }
>>>
>>> .... page initialization afterwards
>>> }
>>>
>>> The strange thing is that it works for one of the pages, for another two
>> - it does not - there is no redirection at all; it goes on with further
>> initializing. The criteria check block is the very same one in each of the
>> pages.
>>>
>>> Appreciate if someone helps!
>>>
>>> Regards,
>>> Martin
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> ---------------------------------------------------------------------
> 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: setResponsePage in the beggining of a constructor does not work

Posted by Steve Swinsburg <st...@gmail.com>.
They don't need to be bookmarkable. You can call specific constructors of a class if you want:
throw new RestartResponseException(new MyClass(something));

cheers,
Steve


On 05/02/2010, at 10:59 AM, Chris Colman wrote:

> Could I use RestartResponseException to redirect to a URL instead of a bookmarkable page?
> 
> My problem is that all of my pages require a parameter (even the home page but that's fine because the Tomcat container server.xml configures the appropriate redirection for me - users never have to enter the parameters in the address bar) but the "Expired Page" page contains a link that does not contain any parameters.
> 
> When a session expires the page that appears attempts to go to the 'home' page without any parameters. If I could either change the expired page's link or do a redirect in the home page's constructor that redirect's to "/" then this would work fine.
> 
> Unfortunately the RestartResponseException seems to only want to redirect to bookmarkable pages. Is there an alternative I could use to redirect to the "/" URL?
> 
>> -----Original Message-----
>> From: Martin Asenov [mailto:mAsenov@velti.com]
>> Sent: Friday, 5 February 2010 12:30 AM
>> To: users@wicket.apache.org
>> Subject: RE: setResponsePage in the beggining of a constructor does not
>> work
>> 
>> Thanks friend! Works great! You saved me a lot of time!
>> 
>> Best regards,
>> Martin
>> 
>> -----Original Message-----
>> From: Major Péter [mailto:majorpetya@sch.bme.hu]
>> Sent: Thursday, February 04, 2010 3:21 PM
>> To: users@wicket.apache.org
>> Subject: Re: setResponsePage in the beggining of a constructor does not
>> work
>> 
>> Hi,
>> 
>> the setresponsepage only marks, that the pagetarget is something else on
>> the end of the cycle, but it isn't stopping the execution of the current
>> page. If you want that, then use:
>> throw new RestartResponseException(getApplication().getHomePage());
>> 
>> Regards,
>> Peter
>> 
>> 2010-02-04 14:16 keltezéssel, Martin Asenov írta:
>>> Hello guys!
>>> 
>>> I've got three pages, where I do certain check in the beginning and if
>> the criteria is not met, I redirect to home page. I make it that way:
>>> 
>>> public MyPageClass {
>>> 
>>>            if (something) {
>>>                        system.out.println("mypageclass - we're in");
>>>                        setResponsePage(getApplication().getHomePage());
>>>            }
>>> 
>>> .... page initialization afterwards
>>> }
>>> 
>>> The strange thing is that it works for one of the pages, for another two
>> - it does not - there is no redirection at all; it goes on with further
>> initializing. The criteria check block is the very same one in each of the
>> pages.
>>> 
>>> Appreciate if someone helps!
>>> 
>>> Regards,
>>> Martin
>> 
>> ---------------------------------------------------------------------
>> 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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


RE: setResponsePage in the beggining of a constructor does not work

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
I tried that approach of looking around the tree but I must have missed
that Exception somehow. Looks like what I was after.

In the end the ExpiredPage solution worked out to be a good approach
because I got to create an ExpiredPage that's styled to the style of the
rest of the site.

> In Wicket it usually helps to look at the classes that are near in the
> class hierarchy. In this case RestartResponseException extends from
> AbstractRestartResponseException. Another subclass of
> AbstractRestartResponseException is RedirectToUrlException, which does
> exactly what you ask.
> 
> Regards,
>     Erik.
> 
> Chris Colman wrote:
> > Could I use RestartResponseException to redirect to a URL instead of
a
> bookmarkable page?
> >
> > My problem is that all of my pages require a parameter (even the
home
> page but that's fine because the Tomcat container server.xml
configures
> the appropriate redirection for me - users never have to enter the
> parameters in the address bar) but the "Expired Page" page contains a
link
> that does not contain any parameters.
> >
> > When a session expires the page that appears attempts to go to the
> 'home' page without any parameters. If I could either change the
expired
> page's link or do a redirect in the home page's constructor that
> redirect's to "/" then this would work fine.
> >
> > Unfortunately the RestartResponseException seems to only want to
> redirect to bookmarkable pages. Is there an alternative I could use to
> redirect to the "/" URL?
> >
> 
> --
> Send from my SMTP compliant software
> Erik van Oosten
> http://day-to-day-stuff.blogspot.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: setResponsePage in the beggining of a constructor does not work

Posted by Erik van Oosten <e....@grons.nl>.
In Wicket it usually helps to look at the classes that are near in the 
class hierarchy. In this case RestartResponseException extends from 
AbstractRestartResponseException. Another subclass of 
AbstractRestartResponseException is RedirectToUrlException, which does 
exactly what you ask.

Regards,
    Erik.

Chris Colman wrote:
> Could I use RestartResponseException to redirect to a URL instead of a bookmarkable page?
>
> My problem is that all of my pages require a parameter (even the home page but that's fine because the Tomcat container server.xml configures the appropriate redirection for me - users never have to enter the parameters in the address bar) but the "Expired Page" page contains a link that does not contain any parameters.
>
> When a session expires the page that appears attempts to go to the 'home' page without any parameters. If I could either change the expired page's link or do a redirect in the home page's constructor that redirect's to "/" then this would work fine.
>
> Unfortunately the RestartResponseException seems to only want to redirect to bookmarkable pages. Is there an alternative I could use to redirect to the "/" URL?
>   

-- 
Send from my SMTP compliant software
Erik van Oosten
http://day-to-day-stuff.blogspot.com/



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


RE: setResponsePage in the beggining of a constructor does not work

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
Could I use RestartResponseException to redirect to a URL instead of a bookmarkable page?

My problem is that all of my pages require a parameter (even the home page but that's fine because the Tomcat container server.xml configures the appropriate redirection for me - users never have to enter the parameters in the address bar) but the "Expired Page" page contains a link that does not contain any parameters.

When a session expires the page that appears attempts to go to the 'home' page without any parameters. If I could either change the expired page's link or do a redirect in the home page's constructor that redirect's to "/" then this would work fine.

Unfortunately the RestartResponseException seems to only want to redirect to bookmarkable pages. Is there an alternative I could use to redirect to the "/" URL?

> -----Original Message-----
> From: Martin Asenov [mailto:mAsenov@velti.com]
> Sent: Friday, 5 February 2010 12:30 AM
> To: users@wicket.apache.org
> Subject: RE: setResponsePage in the beggining of a constructor does not
> work
> 
> Thanks friend! Works great! You saved me a lot of time!
> 
> Best regards,
> Martin
> 
> -----Original Message-----
> From: Major Péter [mailto:majorpetya@sch.bme.hu]
> Sent: Thursday, February 04, 2010 3:21 PM
> To: users@wicket.apache.org
> Subject: Re: setResponsePage in the beggining of a constructor does not
> work
> 
> Hi,
> 
> the setresponsepage only marks, that the pagetarget is something else on
> the end of the cycle, but it isn't stopping the execution of the current
> page. If you want that, then use:
> throw new RestartResponseException(getApplication().getHomePage());
> 
> Regards,
> Peter
> 
> 2010-02-04 14:16 keltezéssel, Martin Asenov írta:
> > Hello guys!
> >
> > I've got three pages, where I do certain check in the beginning and if
> the criteria is not met, I redirect to home page. I make it that way:
> >
> > public MyPageClass {
> >
> >             if (something) {
> >                         system.out.println("mypageclass - we're in");
> >                         setResponsePage(getApplication().getHomePage());
> >             }
> >
> > .... page initialization afterwards
> > }
> >
> > The strange thing is that it works for one of the pages, for another two
> - it does not - there is no redirection at all; it goes on with further
> initializing. The criteria check block is the very same one in each of the
> pages.
> >
> > Appreciate if someone helps!
> >
> > Regards,
> > Martin
> 
> ---------------------------------------------------------------------
> 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


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


RE: setResponsePage in the beggining of a constructor does not work

Posted by Martin Asenov <mA...@velti.com>.
Thanks friend! Works great! You saved me a lot of time!

Best regards,
Martin

-----Original Message-----
From: Major Péter [mailto:majorpetya@sch.bme.hu] 
Sent: Thursday, February 04, 2010 3:21 PM
To: users@wicket.apache.org
Subject: Re: setResponsePage in the beggining of a constructor does not work

Hi,

the setresponsepage only marks, that the pagetarget is something else on
the end of the cycle, but it isn't stopping the execution of the current
page. If you want that, then use:
throw new RestartResponseException(getApplication().getHomePage());

Regards,
Peter

2010-02-04 14:16 keltezéssel, Martin Asenov írta:
> Hello guys!
> 
> I've got three pages, where I do certain check in the beginning and if the criteria is not met, I redirect to home page. I make it that way:
> 
> public MyPageClass {
> 
>             if (something) {
>                         system.out.println("mypageclass - we're in");
>                         setResponsePage(getApplication().getHomePage());
>             }
> 
> .... page initialization afterwards
> }
> 
> The strange thing is that it works for one of the pages, for another two - it does not - there is no redirection at all; it goes on with further initializing. The criteria check block is the very same one in each of the pages.
> 
> Appreciate if someone helps!
> 
> Regards,
> Martin

---------------------------------------------------------------------
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: setResponsePage in the beggining of a constructor does not work

Posted by Major Péter <ma...@sch.bme.hu>.
Hi,

the setresponsepage only marks, that the pagetarget is something else on
the end of the cycle, but it isn't stopping the execution of the current
page. If you want that, then use:
throw new RestartResponseException(getApplication().getHomePage());

Regards,
Peter

2010-02-04 14:16 keltezéssel, Martin Asenov írta:
> Hello guys!
> 
> I've got three pages, where I do certain check in the beginning and if the criteria is not met, I redirect to home page. I make it that way:
> 
> public MyPageClass {
> 
>             if (something) {
>                         system.out.println("mypageclass - we're in");
>                         setResponsePage(getApplication().getHomePage());
>             }
> 
> .... page initialization afterwards
> }
> 
> The strange thing is that it works for one of the pages, for another two - it does not - there is no redirection at all; it goes on with further initializing. The criteria check block is the very same one in each of the pages.
> 
> Appreciate if someone helps!
> 
> Regards,
> Martin

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