0

I am developing an application using jbpm 5.4. I have deployed my workflow in drools-guvnor.I have added variable definitions as follows task1_lname_out, task1_fname_out Then i have mapped DataInputSet and DataOutputSet for Task1.In Task1 , I have mapped DataOutputSet to Variable definitions.

This is my Task1-taskform.ftl

<html>
<body>
<form action="CompleteTaskServlet" method="post" enctype="multipart/form-data">
First Name : <input name="task1_fname_out" type="text"><br>
Second Name : <input name="task1_lname_out" type="text">
<input value="Complete" type="submit"></form>
</body>
</html>

Now i am going to complete task after filling above task form.I use following code to complete task with task data.

Map<String,Object> result=new HashMap();
try {
taskService=API.getTaskService();
Task task = taskService.getTask(taskid);
result.put("Result", "taskInput");//here i can set the input parameter
BlockingGetContentResponseHandler contentResponseHandler            =newBlockingGetContentResponseHandler();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
ObjectOutputStream outS;
if(result!=null){
outS=new ObjectOutputStream(bos);
outS.writeObject(result);
outS.close();
contentData=new ContentData();
contentData.setContent(bos.toByteArray());
contentData.setAccessType(AccessType.Inline);
        }
taskService.start(taskid, user);
taskService.complete(taskid, user, contentData);
contentResponseHandler.waitTillDone(5000);
} catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    };

From drools guvnor, i have mapped DataInputSet ,and Association properly.(Process variables have mapped to DataInputSet). Then, I am going to access next task form, Task2-taskform.ftl

<html>
<body>
First Name:${task1_fname_out}<br>
Last Name: ${task1_lname_out}
<form action="CompleteTaskServlet" method="post" enctype="multipart/form-data">
Age : <input name="task2_age_in" type="text">
<br>
<input value="Complete" type="submit"></form>
</body></html>

Next i am going to access the result like this.

Map<String,Object> results=new HashMap<String,Object>();
long contentId=task.getTaskData().getOutputContentId();
if (contentId != -1) {
Content contents=taskService.getContent(contentId);
Object result=ContentMarshallerHelper.unmarshall(contents.getContent(),null);
results.put("Result",result);
if (result instanceof Map) {
Map<?,?> map=(Map<?,?>)result;
for (Map.Entry<?,?> entry : map.entrySet()) {
if (entry.getKey() instanceof String) {
results.put((String)entry.getKey(),entry.getValue());
out.print("entry.getValue()::"+entry.getValue());
}
}
}
}

My problem is, Task2-taskform.ftl is not displaying Task1-taskform output results. There is no error in DataInput and output mappings, because all works fine via Jbpm console.

Please help me to solve this issue? I am not sure about following line in my code.

 result.put("Result", "taskInput");

I have stuck on this point. please help me ???

Ampm
  • 27
  • 1
  • 7

1 Answers1

0

Are you mapping the result data in your process to a process variable in the first task, and then mapping these variables back as task input params in the second task? Data doesn't get passed automatically, you have to define what data you want to store in the process instance so it can be used later, and what data you want to pass as input for tasks later.

Kris Verlaenen
  • 2,918
  • 1
  • 15
  • 5
  • I use Variable definitions to add Process variables and DataInputSet and DataOutputSet to map task inputs and outputs in drools guvnor. Then what should i do from code level? – Ampm Oct 21 '14 at 10:14
  • If i use rest api to complete task after rendering for ( /gwt-console-server/rs/form/task/{id}/complete ) all works fine . but i want to complete task on my own. Where am i wrong? – Ampm Oct 21 '14 at 10:21