I store a bean as an attribute of the
ActionRequest in the
@ProcessAction method (
GenericPortlet) with the intent that the portlet JSP can access the bean via the
ActionRequest attribute and display the bean's attributes:
1 @ProcessAction(name="testAction")
2 public void testActionURL(ActionRequest request, ActionResponse response)
3 throws PortletException, IOException {
4 ExpandedUser usr = new ExpandedUser();
5 usr.setFirstNamePreferred("John");
6 usr.setLastNamePreferred("Smith");
7 request.setAttribute("employee", usr);
8 }
JSP fragment:
1<form id="<portlet:namespace/>test" action='<portlet:actionURL name="testAction"/>' method="post">
2 <input type="hidden" name="var" value="whatever" />
3 <input type="submit" value="Submit" />
4</form>
5
6<logic:present name="emp">
7 <bean:define id="emp" name="employee"/>
8 <logic:notEmpty name="emp" property="firstNamePreferred">
9 <logic:notEmpty name="emp" property="lastNamePreferred">
10 <bean:write name="emp" property="firstNamePreferred"/> <bean:write name="emp" property="lastNamePreferred"/>
11 </logic:notEmpty>
12 </logic:notEmpty>
13</logic:present>
But the bean does not exist any longer after the portlet is rendered.
How do I have portlet JSP retrieve attributes stored in
ActionRequest?
Please sign in to flag this as inappropriate.