Ensure that the code for the target portlet class meets the following
requirements: - The action must be implemented either as a portlet action, a Faces
action or a Struts action. For portlet actions, you should use the simple
action Strings rather than the deprecated PortletAction class.
- Portlet actions must accept a single parameter. The parameter may
appear as a request parameter, a request attribute, a session attribute, or
an action attribute (deprecated), as specified in the action declaration or
registration.
The following example shows the actionPerformed() method of the OrderDetailPortlet.java in
the Cooperative Portlets application sample from the Sample Gallery. This
portlet accepts the ORDER_ID parameter in its actionPerformed() method. This
parameter corresponds to an input parameter in the binding section of the
portlet's WSDL file ( OrderDetailC2A.wsdl in this example).
...
private static final String PREFIX = "";
public static final String ORDER_ID = PREFIX + "orderId";
public static final String TRACKING_ID = PREFIX + "trackingId";
...
public void actionPerformed (ActionEvent event)
{
// DefaultPortletAction action = (DefaultPortletAction) event.getAction();
String actionName = event.getActionString();
PortletRequest request = event.getRequest();
//An action causes the state to be modified
ShippingUtils.setLastModified(request);
if( getPortletLog().isDebugEnabled() ) {
getPortletLog().debug("OrderDetailActionListener - Action called");
}
if (actionName.equals(ORDER_DETAILS)) {
request.getPortletSession().setAttribute(ACTION_NAME, ORDER_DETAILS);
request.getPortletSession().setAttribute(ORDER_ID, request.getParameter(ORDER_ID));
//We do this as tracking id is an out param in the C2A WSDL file
//We write the tracking id in the request so it can be published by
//the broker in the same event cycle
String orderId = (String) request.getPortletSession().getAttribute(ORDER_ID);
OrderDetail od = ShippingDB.getOrderDetail(request.getParameter(ORDER_ID));
request.getPortletSession().setAttribute(ORDER_DETAIL, od);
request.setAttribute(TRACKING_ID, od.getTrackingId());
} else if (actionName.equals(ORDER_ID_ENTRY)) {
request.getPortletSession().setAttribute(ACTION_NAME, ORDER_ID_ENTRY);
}
}
...