Question

Is there any diffference between these two: This is w.r.t going from ActionPhase to RenderPhase.

1

PortletURL manageUrl = response.createRenderURL();
manageUrl.setParameter("action", "search");

2

ActionResponse.setRenderParameter("action", "search");

When to use one over the other

Was it helpful?

Solution

The first snippet generates an render URL that you will use in your page as a direct link to the render phase with an "action" parameter.

The second snippet of code add an "action" render parameter to the current request, so after the execution of your action phase, the render phase will have access to this new parameter. It can be used for example to pass data from your action phase to your render phase, or select the right render method if you have several render methods (several method annotated with @RenderMapping).

OTHER TIPS

Case 1:

  **Code on Portlet** 

   PortletURL manageUrl = response.createRenderURL();
   manageUrl.setParameter("action", "search");
   request.setAttribute("manageUrl",manageUrl); 

  **Code on Jsp(it can be any view layer)** 

    <a href="${manageUrl}">Click here </a>  

Case 2:

     **It can be any custom process action**
    public void processAction(..)
           {        
            ActionResponse.setRenderParameter("action", "search");
           }

       **It can be any custom render method**
    public void doView(..)
           {        

      System.out.println("Action value :-"+action);      
      ActionResponse.setRenderParameter("action", "search");

            }

The second snippet also has a limitation.You can not use ActionResponse.setRenderParameter("action", "search"); and ActionResponse.sendRedirect("/some url"); simultaneously.

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