Pluto2: Cannot retrieve attribute from doView that set in processAction!

View: New views
2 Messages — Rating Filter:   Alert me  

Pluto2: Cannot retrieve attribute from doView that set in processAction!

by EricMacau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I donwloaded the pluto-trunk and test the pluto2 driver.

I also tried to write a simple portlet as following:

=============================================================================================
public void doView(RenderRequest request, RenderResponse response)
                throws PortletException, IOException {
       
        System.out.println("doView: "  + request.getParameter("name"));
        System.out.println("doView-attr: "  + request.getAttribute("name"));
       
        response.setContentType("text/html");
     PortletContext context = getPortletContext();
     PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(VIEW_PAGE);
     requestDispatcher.include(request, response);

}

public void processAction(ActionRequest request, ActionResponse response)
                throws PortletException, IOException {
       
        String name = request.getParameter("name");
       
        response.setRenderParameters(request.getParameterMap());
       
        request.setAttribute("name", name);
       
        System.out.println("processAction: " + name);
}
=============================================================================================


In the processAction method, I set an attribute "name", but it can't
retrieve in doView. Is it a bug?

Best regards,
Eric

Re: Pluto2: Cannot retrieve attribute from doView that set in processAction!

by ben-143 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> In the processAction method, I set an attribute "name", but it can't
> retrieve in doView. Is it a bug?
>
> Best regards,
> Eric
>

Eric,

Its not a bug.  Action request attributes are not available in the render
phase.  I think there is a runtime option for that in JSR 286, but keeping
those attributes around for possibly multiple render phases has memory
implications.  Similarly, you could use the portlet session for this.

-- Ben