25.3 Broadcasting source data

Using the broadcast feature of the cooperative broker, users can send the same data to all portlets on the page with matching actions. The target cooperative portlet of a broadcast can use the declarative or programmatic approach to publish properties.

To include the broadcast menu item to the HRPortlet, proceed as follows:

1. Open the JSP HRPortlet/Web Content/hrportlet/jsp/html/HRPortletView.jsp.

2. In the encodeProperty tag, include the broadcast attribute so it looks as shown in Example 25-1.

Example 25-1 The broadcast attribute enables the broadcast feature.

 <TD><P>
  <% if (results.getColumnName(col).equalsIgnoreCase("DEPT_NO")) { %>
   <C2A:encodeProperty
    name="DEPT_NOParam"
    namespace="http://www.ibm.com/wps/c2a/examples/hrdetails"
    type="DEPT_NO"
    value="<%=results.getCacheValueAt(row, col).toString()%>" 
    broadcast="true"/>
  <% } %>
  <%=results.getCacheValueAt(row, col)%>
 </P></TD>

3. Test the application as described in the last chapter. You need to include HRPortlet, EmployeeDetailsPortlet and DepartmentDetailsPortlet in the same page. Do not forget to enter the database attribute in the Edit mode of both the Employee and Department Details Portlets.

4. From the cooperative portlet menu, choose Invoke all actions. Now both details portlets display the details of the selected department number.

Figure 25-2 Choose Invoke all actions to broadcast the data to all portlets


Redbooks
ibm.com/redbooks