[jboss-user] [jBPM] - Is there anybody who know how to get a process variable's value when get a task by userid?

星兰 蒋 do-not-reply at jboss.com
Tue Dec 4 07:59:00 EST 2012

星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Is there anybody who know how to get a process variable's value when get a task by userid?"

To view the discussion, visit: https://community.jboss.org/message/779861#779861



In my case,in fact i want to get the vars's value when i get a task by userid. And these values are passed when i start a processinstance.

i set & get values all in myself application. no using the jbpm console. Also no using marshall and unmarshall.

*Set values when start process:*

Map<String,Object> params = new HashMap<String,Object>();
params.put("sales", c.getCreateby());
params.put("contractno", c.getContractno());
params.put("details", c.getDetails());
params.put("amount", c.getAmount());
params.put(role.getRole(), leader.getName());
params.put("accoptor", list.get(0).getName());
getSession().startProcess(definitionId, params);

*Get values when get a task by userid:*

List<TaskSummary> t = sTaskService.getTasksAssignedAsTaskInitiator(idRef, "en-UK");

if(null != t && t.size() > 0){

for(TaskSummary ts : t){
Object obj = getTaskContentInput(ts);
Map<?, ?> map = (Map<?, ?>) obj; 
for (Map.Entry<?, ?> entry : map.entrySet()) { 
System.out.println(entry.getKey() + " = " + entry.getValue()); 
tasks.add(new TaskRef(ts.getId(), ts.getProcessInstanceId() + "", ts.getProcessId(), 
ts.getName(), ts.getCreatedBy().getId(), ts.getStatus() == Status.Suspended, ts.getStatus() != Status.Suspended));


*And the getTaskContentInput method as blow:*

public Object getTaskContentInput(TaskSummary taskSum) {
BlockingGetTaskResponseHandler handlerT = new BlockingGetTaskResponseHandler();
client.getTask(taskSum.getId(), handlerT);
Task task2 = handlerT.getTask();
TaskData taskData = task2.getTaskData();
BlockingGetContentResponseHandler handlerC = new BlockingGetContentResponseHandler();
client.getContent(taskData.getDocumentContentId(), handlerC);
Content content = handlerC.getContent();
ByteArrayInputStream bais = new ByteArrayInputStream(
try {
ObjectInputStream is = new ObjectInputStream(bais);
Object obj = null;

while ((obj = is.readObject()) != null) {
System.out.println("OBJECT: " + obj);
return obj;
} catch (Exception e) {
System.err.print("There was an error reading task input...");
return null;
return null;

*Is My way right or wrong? Would you pls give some advice?*

*Thanks and Best Regards!*

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121204/13306064/attachment.html 

More information about the jboss-user mailing list