How to transfer Objects from Action Phase to Render Phase ?

0 comments



Generally we can send a String object from Action phase to Render phase ,but in case you are using JSR286 API for portlet development then we can also send objects. The following configuration changes are required.

Portlet.xml
<portlet>
...
<container-runtime-option>
<name>javax.portlet.actionScopedRequestAttributes</name>
<value>true</value>
</container-runtime-option>
</portlet>
 Portlet Class

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

Map userProfile = new HashMap();
userProfile.put("userName", "Arun");
request.setAttribute("userProfile", userProfile);
}

public void doView(RenderRequest request,RenderResponse response)
throws PortletException, IOException {

Map userProfile = (Map)renderRequest.getAttribute("userProfile");
}

No comments:

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club