Question

I am using Liferay and Spring MVC and I want to redirect to another portlet and pass it a parameter, but when I try to set render parameters I get this error:

15:20:24,859 ERROR [portal-web.docroot.html.portal.render_portlet_jsp] (http-foo-10.23.243.3-8080-7) java.lang.IllegalStateException: Set render parameter has already been called

at com.liferay.portlet.ActionResponseImpl.sendRedirect(ActionResponseImpl.java:48) at sk.foo.showcasePortlet.ShowcaseController.redirect(ShowcaseController.java:65)

The showcaseController's method which is being resolved contains just the assignement and the redirect:

@ActionMapping(params = { "action=redirect" })
public void redirect(ActionRequest request, ActionResponse response) 
    throws IOException {

    response.setRenderParameter("path", request.getParameter("path"));
    response.sendRedirect("/path/to/portlet");
}

Why can't I assign that parameter? When I remove the line the redirection works, but the problem is that the portlet which the user is being redirected to expects a string parameter "path":

@RenderMapping
public String barBaz(RenderRequest request, @RequestParam String path){
    // ...
    return "some/jsp";
}

How can I pass the parameter to the barBaz method in another portlet, please?

Was it helpful?

Solution

You exception says this IllegalStateException: Set render parameter has already been called

Be aware that this interceptor is calling setRenderParameter on the ActionResponse, which means that you cannot call sendRedirect in your handler when using this interceptor. If you need to do external redirects then you will either need to forward the mapping parameter manually or write a different interceptor to handle this for you

DOC

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top