Enabling cooperative sources
To enable a cooperative source, perform the following steps.
- In the Project Explorer view, select a portlet or the Portlet Deployment Descriptor. Portlets are displayed when you expand the Portlet Deployment Descriptor node under the portlet project folder.
- Right-click the desired portlet, and select...
Cooperative | Enable Source...from the pop-up menu. The Enable Cooperative Source dialog opens. Alternatively, open a JSP page and select...
Page | Cooperative | Enable Source...from the menu.
- Provide values for the following fields:
- Data type
- Specify a name of the data type of the data to be transferred by the source portlet. Alternatively, if the data type you want to publish has been already declared, click the Browse button to open the Select Type dialog and select a WSDL data type that you wish to publish. The data type and the namespace in the WSDL file will be specified in each field. The specified value will be used to declare the data type in the <types> element in WSDL file.
- Namespace
- Specify the namespace for the type. For example, http://www.yourco.com/c2a. The specified value will be stored in a WSDL file and will be used as namespace to specify output property.
- Bound to
- Specify where the parameter value is bound. Currently, this attribute can specify one of the following values only:
request-parameter: Value is bound as a parameter in the PortletRequest object. This is the default value if the boundTo attribute is omitted. Note that for output parameters, a different value should usually be specified as the default PortletRequest implementation provided by WebSphere Portal does not allow parameters to be set during action processing. request-attribute: Value is bound as an attribute in the PortletRequest object. session: Value is bound to the PortletSession object. It is also possible to use this attribute, without using the Click-to-Action interface provided, when enabling the source portlet .
The following example shows the actionPerformed() method of the OrderDetailPortlet.java in the Cooperative Portlets application sample from the Sample Gallery. The portlet passes the TRACKING_ID parameter to property broker in its actionPerformed() method. This parameter corresponds to an output parameter in the binding section of the portlet's WSDL file ( OrderDetail.wsdl, in this example).
OrderDetailPortlet.java
OrderDetailPortlet.java ... private static final String PREFIX = ""; //$NON-NLS-1$ public static final String ACTION_NAME = PREFIX + "actionName"; //$NON-NLS-1$ public static final String ORDER_DETAILS = PREFIX + "orderDetails"; //$NON-NLS-1$ public static final String ORDER_ID_ENTRY = PREFIX + "orderIdEntry"; //$NON-NLS-1$ public static final String ORDER_ID = PREFIX + "orderId"; //$NON-NLS-1$ public static final String ORDER_DETAIL_BEAN = PREFIX + "orderDetailBean"; //$NON-NLS-1$ public static final String ORDER_DETAIL = PREFIX + "orderDetail"; //$NON-NLS-1$ public static final String TRACKING_ID = PREFIX + "trackingId"; //$NON-NLS-1$ ... public void actionPerformed(ActionEvent event) { String actionName = event.getActionString(); PortletRequest request = event.getRequest(); //An action causes the state to be modified ShippingUtils.setLastModified(request); if (getPortletLog().isDebugEnabled()) { getPortletLog().debug(Messages.getString("OrderDetailPortlet_action_entry")); //$NON-NLS-1$ } 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 */ 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); } } ...OrderDetail.wsdl (The property broker receives the tracking ID parameter from the request attribute.)
... <binding name="OrderDetailBinding" type="tns:OrderDetail_Service"> <portlet:binding></portlet:binding> <operation name="order_Detail"> <portlet:action name="orderDetails" type="simple" caption="Order.Details" description="Get.details.for.specified.order.id"/> <input> <portlet:param name="orderId" partname="order_Id" caption="order.id"/> </input> <output> <portlet:param name="trackingId" partname="tracking_Id" boundTo="request-attribute" caption="tracking.id"/> </output> </operation> </binding> ...- Source portlet (Required)
- Specify the concrete portlet to be enabled as the cooperative source.
For example, you can specify the following values:
- Click OK. The cooperatively-enabled portlet is shown with a source portlet icon ( ) in the Project Explorer view.
The Enable Cooperative Source action performs the following tasks for you:
- Modifies web.xml to add a servlet class entry to refer to the property broker classes:
<servlet-class>com.ibm.wps.pb.wrapper.PortletWrapper</servlet-class> <init-param> <param-name>c2a-application-portlet-class</param-name> <param-value>servlet-class</param-value> </init-param>- Modifies portlet.xml to add configuration parameters to each concrete portlet that exposes actions to the property broker through the WSDL file, and specifies the base name of a national language resource file.
<config-param> <param-name>c2a-action-descriptor</param-name> <param-value>WSDL file</param-value> </config-param> <config-param> <param-name>c2a-nls-file</param-name> <param-value>resource bundle name</param-value> </config-param>- Imports an additional library, pbportlet.jar, to /WEB-INF/lib in the portlet project for use by the property broker.
- Creates the specified WSDL file with the following sections:
- <definitions>
- Acts as root.
- <types>
- The data type is declared using XML Schema Datatypes (XSD).
- <message>
- An output message.
- <portType>
- Defines an abstract collection of operations. <output>.
- <binding>
- Always extended to <portlet:binding> to identify the section as a cooperative binding extension for portlet action invocation.
Related concepts
Developing cooperative portlets
Related tasks
Enabling existing portlets for cooperation
Enabling cooperative targets
Inserting Click-to-Action encodeProperty
Inserting Click-to-Action encodeProperties
Editing Click-to-Action encodeProperty
Editing Click-to-Action encodeProperties
Related information
Web