Pattern 1: setRenderParameter
One way is to set render parameter(s) in action phase using setRenderParameter
as following:
actionResponse.setRenderParameter("statusparam", "error");
and then get using:
String status = renderRequest.getParameter("statusparam");
or
String status = ParamUtil.getString(renderRequest, "statusparam");
Pattern 2: Global property
Other way is to put a global property in action class, assign it value in action method then it would be accessible in render method as well.
public class MyPortletAction extends GenericPortlet {
String statusparam = "";
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) {
if(statusparam != ""){
// Perform operation as per your requirement
}
}
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) {
// Set statusparam here:
statusparam = "error";
}
}
Pattern 3: queryString
While, if you want to pass it as queryString
parameter, then you can extract it from HttpServletRequest
object in render phase as following:
HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
String statusparam = request.getParameter("statusparam");
redirect
variable? If you use the PortletURL (e.g. via PortletURLUtil), you can use thesetParameter(String name, String value)
method. – Jozef Chocholacek