Hi,
We had the requirement that we needed to use RedirectPolicy.NEVER_REDIRECT for
a single page in our app .
We used this code:
setPageRendererProvider(new IPageRendererProvider() {
@Override
public PageRenderer get(final RenderPageRequestHandler context) {
return new WebPageRenderer(context) {
@Override
protected RedirectPolicy getRedirectPolicy() {
RedirectPolicy result;
if (!((WebRequest) RequestCycle.get().getRequest()).isAjax()
& context.getPage() instanceof ExternalShareDocumentPage) {
result = RedirectPolicy.NEVER_REDIRECT;
} else {
result = super.getRedirectPolicy();
return result;
};
});
This seemed to work fine. However we made it live in production and we
noticed that we where getting "HTTP Status 500 - Cannot call sendRedirect()
after the response has been committed" a lot. It seemed to happen with a
flow like the following which was nothing to do with the
ExternalShareDocumentPage
tweak:
User clicks on link which does a setResponcePage(foo1.class)
in the constructor of foo1.class there is:
if (certainCondition) {
throw new RestartResponseException(foo2.class)
What I don't understand is why this is happening. It seems that by setting
the PageRenderProvider the way the redirects/commit seems to change.
Any ideas?
We had the requirement that we needed to use RedirectPolicy.NEVER_REDIRECT for
a single page in our app .
We used this code:
setPageRendererProvider(new IPageRendererProvider() {
@Override
public PageRenderer get(final RenderPageRequestHandler context) {
return new WebPageRenderer(context) {
@Override
protected RedirectPolicy getRedirectPolicy() {
RedirectPolicy result;
if (!((WebRequest) RequestCycle.get().getRequest()).isAjax()
& context.getPage() instanceof ExternalShareDocumentPage) {
result = RedirectPolicy.NEVER_REDIRECT;
} else {
result = super.getRedirectPolicy();
return result;
};
});
This seemed to work fine. However we made it live in production and we
noticed that we where getting "HTTP Status 500 - Cannot call sendRedirect()
after the response has been committed" a lot. It seemed to happen with a
flow like the following which was nothing to do with the
ExternalShareDocumentPage
tweak:
User clicks on link which does a setResponcePage(foo1.class)
in the constructor of foo1.class there is:
if (certainCondition) {
throw new RestartResponseException(foo2.class)
What I don't understand is why this is happening. It seems that by setting
the PageRenderProvider the way the redirects/commit seems to change.
Any ideas?