// Call the gettaskinstances method of homebean to obtain a list. The name of each element in the list is Var = "taskinstance"
<H: datatable value = "# {homebean. taskinstances}" Var = "taskinstance" headerclass = "tableheader" columnclasses = "tablecell">
// H: column indicates a column, which is equivalent to TD in JSP
<H: column>
// F: facet indicates the list header.
<F: facet name = "Header">
<H: outputtext value = "task form link"/>
</F: facet>
// H: commandlink is equivalent to our common href. Action indicates the action to be executed after clicking
<H: commandlink action = "# {homebean. selecttaskinstance}">
// F: Param is the method for passing variables in JSF.
<F: Param name = "taskinstanceid" value = "# {taskinstance. ID}"/>
// H: outputtext indicates the name of the task to be displayed.
<H: outputtext value = "# {taskinstance. name}"/>
</H: commandlink>
</H: column>
<H: column>
<F: facet name = "Header">
<H: outputtext value = "process"/>
</F: facet>
<H: outputtext value = "# {taskinstance. taskmgmtinstance. taskmgmtdefinition. processdefinition. name}"/>
</H: column>
<H: column>
<F: facet name = "Header">
<H: outputtext value = "version"/>
</F: facet>
<H: outputtext value = "# {taskinstance. taskmgmtinstance. taskmgmtdefinition. processdefinition. Version}"/>
</H: column>
</H: datatable>
The above JSF code shows the list of tasks of the users currently entering the system. Click a Task Name and run the following code:
Homebean. Java:
Public String selecttaskinstance (){
// Get the task instance id from Request Parameter
Long taskinstanceid = jsfhelper. GETID ("taskinstanceid ");
Taskinstance = taskmgmtsession. loadtaskinstance (taskinstanceid );
Taskbean. initialize (taskinstance );
Return "task ";
}
Here, the method for obtaining parameter from the request is as follows:
Public static long GETID (string parametername ){
Long value =-1;
String valuetext = (string) facescontext. getcurrentinstance (). getexternalcontext (). getrequestparametermap (). Get (parametername );
Try {
Long id = new long (valuetext );
Value = ID. longvalue ();
} Catch (numberformatexception e ){
Throw new runtimeexception ("couldn't parse '" + parametername + "' = '" + valuetext + "' as a long ");
}
Return value;
}
Jbpm encapsulates parameter reading in its own way to simplify and develop quickly.