I am stuck with a probably simple Spring Portlet redirect and jsp render problem in Liferay.
I have two Pages in Liferay page1 and page2 and one spring mvc portlet portletA with two JSPs defaultView.jsp and second.jsp.
page1 and page2 both instantiate portletA.
portletA loads by default the defaultView.jsp by calling the @RenderMapping() method.
DefaultViewController:
@RenderMapping
public String renderDefaultView() {
return "defaultView";
}
From defaultView.jsp the liferay page2 can be called by http redirect (@ActionMapping resp.sendRedirect())
defaultView.jsp:
$(nRow).click(function() {
window.location.href = "<portlet:actionURL name='doGotoPage2' />"
});
DefaultViewController:
@ActionMapping("doGotoPage2")
public void doGoToMedicalAid(ActionRequest req,
ActionResponse resp) {
try {
resp.sendRedirect("/group/project/page2");
} catch (IOException ex) {
Logger.getLogger(DefaultViewController.class.getName()).log(Level.SEVERE, null, ex);
}
}
Now I am wondering
how can I tell portletA to call a different @RenderMapping method on page2 after the redirect from page1 ?
I would like portletA to render second.jsp on page2:
@RenderMapping(value = "renderSecondPage")
public String renderSecondPage() {
return "second";
}
As far as I understand, I can't set renderParameters in the action phase before or after a sendRedirect!
For example, this doesn't work and results in an java.lang.IllegalStateException: Set render parameter has already been called
resp.sendRedirect("/group/project/page2");
resp.setRenderParameter("render", "renderSecondPage");
Thanks a lot for your help!