Pages

Sunday, October 18, 2015

Humantask Rendering in WSO2 Business Process Server [WSO2 BPS]

Little introduction about WS-Humantask

WS-Humantask is defined to integrate humans into enterprise integration. When task request received by humantask engine, it create instance of the task with received request information. Then assignee or potential owner can claim the task and work on it and complete it. On completion response message is sent to the callback service. That's the most basic usage of WS-Humantask.  

WSO2 Business Process Server (WSO2 BPS) includes humantask engine which compliance with WS-HumanTask Specification Version 1.1 [1].

Humantask Rendering

When humantask instance created it can be presented to its (potential) owners to claim task and perform work using Task Client application. An easily customizable client application (humantask-explorer) with main basic functionalities is packed with WSO2 Business Process Server.  

When user selects interested task, client application should render task allowing user to view information related to task instance. 


WS-Humantask provide container to provide rendering information to Task Client application. And task clients (eg: humantask-explorer) use these information and construct the user interface. The container mentioned above for rendering a task’s information is tasks rendering element.

 

Task rendering details are out of the scope of WS-Humantask. So WSO2 input and output renderings have introduced WSO2 Business Process Server 3.5.0 onwards.

Why we introduced humantask rendering support:


In previous versions of WSO2 BPS did not support task rendering, instead you had two options with the help of HumanTaskClientAPIAdmin adminservice:
  1. Build your own client application including task information rendering for each task definition
  2. Using humantask client built into management console. In this case you have to package separate .jsp pages to display input, output and response  which display input data, user workspace and create response message.

Above both methods introduce high workload per task definition (in method 2) and unable to implement client applications which support almost any humantasks (client applications are tightly coupled with each humantask definition), which makes adding new task much complicated work. That's why, with new release WSO2 BPS 3.5.0 onwards we introduce task rendering support. 


Syntax:


Description


<renderings>

Within “renderings” element rendering types are listed.
<rendering>
xmlns, type
WSO2 Business Process Server supports two main rendering types: wso2:input and wso2:output


  • The type of the rendering is specified by the “type” attribute as follows:
    • If the rendering elements listed under <rendering> are input renderings : type="wso2:input"
    • If the rendering elements listed under <rendering> are output renderings : type="wso2:output"
<wso2:input>

wso2:input rendering type is used to render input information to the task instance in the user interface. Each information is represented by <wso2:element> which list input information that need to display as label / value pairs.

Format of rendering input element (<wso2:element>) as follows:

<wso2:element id=”[Unique id for the display element]”>
   <wso2:label>[Label to display for the input element]</wso2:label>
   <wso2:value>[xpath to get the value from the input message / presentationParameter]</wso2:value>
</wso2:element>

Attributes
id - Unique ID for each element

Child elements
<wso2:label> - Label (or text) to display with the value
<wso2:value> - The value to display with the label. This value can be extracted from the input message (by providing xpath) or by presentation parameters.

Example 01 : retrieving value by xpath
<wso2:element id="custId">
  <wso2:label>Customer Identifier</wso2:label>
  <wso2:value>/test10:ClaimApprovalData/test10:cust/test10:id</wso2:value>
</wso2:element>

Example 02 : Set value by presentation parameter defined in the presentationParameters in humantask definition
<wso2:element id="fname">
  <wso2:label>First Name</wso2:label>
  <wso2:value>$firstname$</wso2:value>
</wso2:element>


HT_inputs.png






<wso2:output>

wso2:output rendering is used to render user workspace (to generate html form that need to filled by the task assignee) and to populate response message to the callback service when task instance get completed. Each form element is represented by <wso2:element>.

Format of the output rendering element () as follows:
<wso2:element id="[unique id for each element]">
   <wso2:label>[Label to display for the form field]</wso2:label>
   <wso2:xpath>[xpath of the element in the output message to be filled with this form field]</wso2:xpath>
  <wso2:value type="[string | boolean | Int | double | list]">[comma separated values for list type and boolean type]</wso2:value>
  <wso2:default>[default value for above mentioned value element]</wso2:default>*
</wso2:element>

Attributes
id - Unique ID for each form element

Child elements
  • <wso2:label> - Label to display for the form field
  • <wso2:xpath> - Xpath of the element in the output response message to be filled with this form field input content
  • <wso2:value type=””> - The “type” attribute is used to define the type of the form field.
    • string : provide textarea
    • int / double : provide number input
    • boolean : provide radio buttons. Texts to display with two radio buttons should provide as comma separated values within value element, with respective to “true” and “false”.
    • list : provide dropdown selection. Texts to display in the dropdown list should provide as comma separated values.
  • <wso2:default> - Can provide default value to display in the form

Example 01:

<htd:rendering type="wso2:output">
  <wso2:outputs>
      <wso2:element id="approve">
         <wso2:label>Loan Status</wso2:label>
             <wso2:xpath>/test10:ClaimApprovalResponse/test10:approved</wso2:xpath>
          <wso2:value type="boolean">Approved, Not approved</wso2:value>
          <wso2:default>Disapproved</wso2:default>
     </wso2:element>
     <wso2:element id="loanTypeSelectList">
          <wso2:label>Loan Type</wso2:label>
          <wso2:xpath>/test10:ClaimApprovalResponse/test10:loanType</wso2:xpath>
          <wso2:value type="list">car loan, house loan, development loan, education loan</wso2:value>
          <wso2:default>house loan</wso2:default>
     </wso2:element>
     <wso2:element id="loadDescription">
          <wso2:label>Loan Description</wso2:label>
          <wso2:xpath>/test10:ClaimApprovalResponse/test10:description</wso2:xpath>
          <wso2:value type="string"></wso2:value>
          <wso2:default>car loan</wso2:default>
     </wso2:element>
     <wso2:element id="loanInterestAlteration">
          <wso2:label>Loan Interest Alteration</wso2:label>
          <wso2:xpath>/test10:ClaimApprovalResponse/test10:interest</wso2:xpath>
          <wso2:value type="int"></wso2:value>
          <wso2:default>1000</wso2:default>
     </wso2:element>
  </wso2:outputs>
</htd:rendering>


Generated form in humantask-explorer will be shown as follows
HT_outputRendering.png