You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "prasad.bhandagi" <pr...@marsh.com> on 2014/12/24 16:30:11 UTC

setResponsePage forward solution options

I am calling setResponsePage(new StatefulPage()), which then redirects the
response, as the default Application level RenderStrategy is
REDIRECT_TO_BUFFER


Only for one scenario I need to forward the request instead of redirecting,
as I need to maintain the original URL for certaing marketing javascripts to
work correctly.

To achieve this I came across few options. 
1) Change RenderStrategy to ONE_PASS_RENDER - However this is application
level flag and I do not want to change across the entire application.
Required only for a specific scenario.

2) WebRequest.shouldPreserveClientUrl - However this is a method that needs
to be overriden and I am not sure if I can extend the WebRequest class and
override this method. Does not seem like a good option.

3) Write my own method as below. This is the same code as in
RequestCycle.setResponsePage(). I have only changed the
RenderPageRequestHandler.RedirectPolicy to NEVER_REDIRECT. Calling this
method for the specific scenario will ensure only this request will get
forwarded instead of redirect.

	public void setResponseForwardPage(IRequestablePage page)
	{
		if (page instanceof Page)
		{
			((Page)page).setStatelessHint(false);
		}
		getRequestCycle().scheduleRequestHandlerAfterCurrent(new
RenderPageRequestHandler(new PageProvider(page),
			RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT));
	}
While this does my job, I am still wondering if there is a better way to
achieve this. 
Does anyone have any other thoughts to achieve this requirement or is this
the best approach?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/setResponsePage-forward-solution-options-tp4668893.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: setResponsePage forward solution options

Posted by "prasad.bhandagi" <pr...@marsh.com>.
Created ticket https://issues.apache.org/jira/browse/WICKET-5797

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/setResponsePage-forward-solution-options-tp4668893p4668908.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: setResponsePage forward solution options

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

Option 3) is the correct way.
This question has been asked recently by someone else. Maybe we should add
a convenience method for this in Wicket.
Please create a ticket so we don't forget!
On Dec 24, 2014 5:31 PM, "prasad.bhandagi" <pr...@marsh.com>
wrote:

> I am calling setResponsePage(new StatefulPage()), which then redirects the
> response, as the default Application level RenderStrategy is
> REDIRECT_TO_BUFFER
>
>
> Only for one scenario I need to forward the request instead of redirecting,
> as I need to maintain the original URL for certaing marketing javascripts
> to
> work correctly.
>
> To achieve this I came across few options.
> 1) Change RenderStrategy to ONE_PASS_RENDER - However this is application
> level flag and I do not want to change across the entire application.
> Required only for a specific scenario.
>
> 2) WebRequest.shouldPreserveClientUrl - However this is a method that needs
> to be overriden and I am not sure if I can extend the WebRequest class and
> override this method. Does not seem like a good option.
>
> 3) Write my own method as below. This is the same code as in
> RequestCycle.setResponsePage(). I have only changed the
> RenderPageRequestHandler.RedirectPolicy to NEVER_REDIRECT. Calling this
> method for the specific scenario will ensure only this request will get
> forwarded instead of redirect.
>
>         public void setResponseForwardPage(IRequestablePage page)
>         {
>                 if (page instanceof Page)
>                 {
>                         ((Page)page).setStatelessHint(false);
>                 }
>                 getRequestCycle().scheduleRequestHandlerAfterCurrent(new
> RenderPageRequestHandler(new PageProvider(page),
>
> RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT));
>         }
> While this does my job, I am still wondering if there is a better way to
> achieve this.
> Does anyone have any other thoughts to achieve this requirement or is this
> the best approach?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/setResponsePage-forward-solution-options-tp4668893.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
>
>