Hi,
I am wondering what is the best practise loading data for a user task. I want to show all data that was saved in the last user tasks in a new html form in a new usertask (e.g.“Show Data”). So I have to fill the variables that are in the html form “show_data.html”.
<div class="form-group">
<label for="firstName">Vorname:</label>
<input class="form-control"
cam-variable-type="String"
cam-variable-name="firstName"
name="firstName" readonly="readonly"readonly="readonly"/>
...
Therefore I need access to the delegate execution object to set the data in the variables:
delegateExecution.setVariable("firstName", firstName);
delegateExecution.setVariable("lastName", lastName)
I thought, a tasklistener at the event “create” should do this. But I do not know how to get the delegate execution object.
In the task listener I only have the delegateTask object.
public class LoadDataForSecTaskListener implements TaskListener{
@Override
public void notify(DelegateTask delegateTask) {
}
}
But I am also not sure if it is the right way - maybe there is some other way to set the data?
Thanks for you ideas!
Nicole
Hi,
I have got another question which is related to my first question. In my process I always have a usertask where someone can fill in his data. To save the data I have a service task after that.


public void saveOrUpdateMasterData(DelegateExecution delegateExecution) throws OFVPersistenceException { ...
Map<String, Object> variables = delegateExecution.getVariables();
managedStudent.setThmUid((String) variables.get("thmUid"));
managedStudent.setFirstName((String) variables.get("firstName"));
managedStudent.setLastName((String) variables.get("lastName")); ...
}
Is it better to do this with a listener? For the user that looks at the process diagram it would be more “beautiful” if he has not to see every service task, I think. But then I need the delegateExecution object, too.
Hi @NickiMueller,
it depends. If you need the “Save masterdata” task after each user task and the business people didn’t like the additional service task, I would hide the call in a listener.
Form the other side: as listeners are hiding information from the reader of the process model, I’m using them carefully.
Hope this helps, Ingo
1 Like
Hi @Ingo_Richtsmeier,
thank you for the reply. This answers my second question. I only save my “masterdata” one time, so do it in a service task.
Have you got ideas about loading data for a user task? (I described my problem in the first thread). When I want to load data with a task listener (is that best practise?) how can I set the process variables? The method “notify” only gives me “delegateTask” and I need “delegateExecution” for set processVariables.
Thanks a lot,
Nicole
Hi
This blog post may be of interest…
regards
Rob