You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Evgheni Emelianov <e....@gmx.net> on 2013/08/10 19:02:21 UTC

AbstractRequestCycleListener redirect

Hi, i habe a question about redirects in AbstractRequestCycleListener, i have functionality in onBeginRequest(RequestCycle cycle) hich checks wether the requested page should be showed or not, if its not the case then user should be redirected/forwarded to my custom exception page, but as i see i can not simply redirect user to this page in this method, if i do so i get application server error: 
HTTP Status 500 - Cannot call sendRedirect() after the response has been committed


has anyone good approach to this problem ob advice for me?


Evgheni

Re: AbstractRequestCycleListener redirect

Posted by Martin Grigorov <mg...@apache.org>.
https://issues.apache.org/jira/browse/WICKET-4433

I remembered there is an open issue about this.


On Mon, Aug 12, 2013 at 2:05 PM, vineet semwal <vi...@gmail.com>wrote:

> try this approach.. throw your custom exception after the checks and catch
> the exception in onexception and then redirect ..
>
>
> On Mon, Aug 12, 2013 at 4:30 PM, Evgheni Emelianov <e.emelianov@gmx.net
> >wrote:
>
> > i did, but the error comes event without, do you have any advice for me
> > how i can implement redirect in this listener?
> >
> >
> > Evgheni
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> regards,
>
> Vineet Semwal
>

Re: AbstractRequestCycleListener redirect

Posted by vineet semwal <vi...@gmail.com>.
try this approach.. throw your custom exception after the checks and catch
the exception in onexception and then redirect ..


On Mon, Aug 12, 2013 at 4:30 PM, Evgheni Emelianov <e....@gmx.net>wrote:

> i did, but the error comes event without, do you have any advice for me
> how i can implement redirect in this listener?
>
>
> Evgheni
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
regards,

Vineet Semwal

Re: AbstractRequestCycleListener redirect

Posted by Evgheni Emelianov <e....@gmx.net>.
i did, but the error comes event without, do you have any advice for me how i can implement redirect in this listener?


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


Re: AbstractRequestCycleListener redirect

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Mon, Aug 12, 2013 at 1:30 PM, Evgheni Emelianov <e....@gmx.net>wrote:

> here is the code:
>
>     getRequestCycleListeners().add(new AbstractRequestCycleListener() {
>
>        @Override
>        public void onBeginRequest(RequestCycle cycle)
>        {
>
>         // some checks and settings before, if my application is locked,
> then redirect should happen
>        cycle.setResponsePage(SystemLockedPage.class);

        // i am not sure about #processRequestAndDetach() was just to try
> case
>        cycle.processRequestAndDetach();
>

You should not use this. Remove it.


>        return;
>        }
>
>        }
>
>     });
>
>
>
> Am 12.08.2013 um 10:36 schrieb Martin Grigorov <mg...@apache.org>:
>
> > Hi,
> >
> > Can you show us your code ?
> > The response shouldn't be committed so early in the request cycle.
> >
> >
> >
> > On Sat, Aug 10, 2013 at 8:02 PM, Evgheni Emelianov <e.emelianov@gmx.net
> >wrote:
> >
> >> Hi, i habe a question about redirects in AbstractRequestCycleListener, i
> >> have functionality in onBeginRequest(RequestCycle cycle) hich checks
> wether
> >> the requested page should be showed or not, if its not the case then
> user
> >> should be redirected/forwarded to my custom exception page, but as i
> see i
> >> can not simply redirect user to this page in this method, if i do so i
> get
> >> application server error:
> >> HTTP Status 500 - Cannot call sendRedirect() after the response has been
> >> committed
> >>
> >>
> >> has anyone good approach to this problem ob advice for me?
> >>
> >>
> >> Evgheni
>
>

Re: AbstractRequestCycleListener redirect

Posted by Evgheni Emelianov <e....@gmx.net>.
here is the code:

    getRequestCycleListeners().add(new AbstractRequestCycleListener() {

       @Override
       public void onBeginRequest(RequestCycle cycle)
       {
   
     	// some checks and settings before, if my application is locked, then redirect should happen
       cycle.setResponsePage(SystemLockedPage.class);
	// i am not sure about #processRequestAndDetach() was just to try case
       cycle.processRequestAndDetach();
       return;
       }
   
       }

    });



Am 12.08.2013 um 10:36 schrieb Martin Grigorov <mg...@apache.org>:

> Hi,
> 
> Can you show us your code ?
> The response shouldn't be committed so early in the request cycle.
> 
> 
> 
> On Sat, Aug 10, 2013 at 8:02 PM, Evgheni Emelianov <e....@gmx.net>wrote:
> 
>> Hi, i habe a question about redirects in AbstractRequestCycleListener, i
>> have functionality in onBeginRequest(RequestCycle cycle) hich checks wether
>> the requested page should be showed or not, if its not the case then user
>> should be redirected/forwarded to my custom exception page, but as i see i
>> can not simply redirect user to this page in this method, if i do so i get
>> application server error:
>> HTTP Status 500 - Cannot call sendRedirect() after the response has been
>> committed
>> 
>> 
>> has anyone good approach to this problem ob advice for me?
>> 
>> 
>> Evgheni


Re: AbstractRequestCycleListener redirect

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Can you show us your code ?
The response shouldn't be committed so early in the request cycle.



On Sat, Aug 10, 2013 at 8:02 PM, Evgheni Emelianov <e....@gmx.net>wrote:

> Hi, i habe a question about redirects in AbstractRequestCycleListener, i
> have functionality in onBeginRequest(RequestCycle cycle) hich checks wether
> the requested page should be showed or not, if its not the case then user
> should be redirected/forwarded to my custom exception page, but as i see i
> can not simply redirect user to this page in this method, if i do so i get
> application server error:
> HTTP Status 500 - Cannot call sendRedirect() after the response has been
> committed
>
>
> has anyone good approach to this problem ob advice for me?
>
>
> Evgheni