Sunday, September 28, 2014

BPEL 1.1: While Activity & Traverse through Collection

Following topic will help you to understand one of BPEL Advanced activities 'While' usage & how to traverse/iterate through data collection.

1. Create two variables in your BPEL as mentioned below.

    <variable name="Counter" type="xsd:int"/>
    <variable name="Nodes" type="xsd:int"/>

2. Add Assign activity to flow.

>  set Counter variable value to 1 &
>  count the number of nodes in data collection and assign to Nodes variable
    <assign name="InitializeVariables">
        <from expression="1"/>
        <to variable="Counter"/>
        <from expression="ora:countNodes('InputVariable','EmpCollection','/ns2:EmpCollection/ns2:Emp')"/>
        <to variable="Nodes"/>

Note: Typically use the expression builder to identify the element then replace the bpws:getVariableData with ora:countNodes.

3. Add While activity and specify condition as needed.

   condition="bpws:getVariableData('Counter') &lt;= bpws:getVariableData('Nodes')"
4. Access record at particular index in the array using []. Specify Counter variable to iterate through each record in collection.


5. Increment Counter in the end. Sample While Activity block provided below.

    <while name="WhileMultiNodes"
           condition="bpws:getVariableData('Counter') &lt;= bpws:getVariableData('Nodes')">
      <sequence name="Sequence">
        <assign name="AssignValue">
            <from variable="InputVariable"
            <to variable="empID"/>
        <assign name="IncrementCounter">
            <from expression="bpws:getVariableData('Counter') + 1"/>
            <to variable="Counter"/>

ADF: Export only Selected Rows from Table

Following post helps you to export only selected rows from ADF table.

We all know that af:exportCollectionActionListener operation allows to export rows from ADF table. by default it exports all the rows exists in the table.

Default af:exportCollectionActionListener usage:

  <af:commandButton text="Export Rows" id="cb1">
          <af:exportCollectionActionListener exportedId="t1"   -- t1 refers to ID for the ADF table

If you want to export the selected rows only from ADF table,  af:exportCollectionActionListener tag contains another attribute named exportedRows.

exportedRows --> valid values 'all' or 'selected'have to modify our above code as shown below.

  <af:commandButton text="Export Selected Rows" id="cb1">
          <af:exportCollectionActionListener exportedId="t1"