cancel
Showing results for 
Search instead for 
Did you mean: 

Generic Java delegate to validate task variables.

vadaliarchita
Champ in-the-making
Champ in-the-making
Hello,

   I am new to BPMN and Activiti. I have a generic java delegate extending TaskActivityBehavior. This would be used by multiple tasks. i.e. multiple process definitions would have this in class attribute. Each of these ServiceTasks using this class would have different set of variables mostly strings. What is the best way to specify the variables in the xml? Using <activito:field> or <property> or iospecification?.

Also, when i add variables to execution, the variables need not be present in the task definition. How to i verify that the variable i am setting is actually specified in task definition if i do not use expression?

Also is there a way to retrieve the variables from task definition for validation purposes?

-Thanks
3 REPLIES 3

trademak
Star Contributor
Star Contributor
You can use the activiti:field element for that.
I don't understand your other questions, can you explain them in a bit more detail?

Best regards,

vadaliarchita
Champ in-the-making
Champ in-the-making
Thanks for your quick response.

If i have one java delegate which is used by multiple tasks say 4. Each of these 4 tasks will have different set of variables. Ex: task 1 will have v1, task 2 will have v2 etc. I do not want to declare all of them as expressions in the JavaDelegate because if i add a new task which will use the same delegate i have to keep adding the new expression. In this scenario what would be the best way to define the variables in my bpmn file?

Also , when i use execution.setVariable or execution.getVariable(""), the variable need not be defined in the bpmn file as task variable. How do i know if that variable is defined in the bpmn file?

Is there a way to get all task variables declared for a given task from process definition?

Thanks.

jbarrez
Star Contributor
Star Contributor
simply use  Map<String, Object> getVariables(String taskId); on taskService?