Jaber C. Mourad [
http://community.jboss.org/people/newbeewan] replied to the discussion
"Access to variable via EL ?"
To view the discussion, visit:
http://community.jboss.org/message/546401#546401
--------------------------------------------------------------
Hi,
My need seems to be pretty simple !
First :
I'have a task, owned by a user.
At the end of the task, I want to record the userid of the owner into a process variable
using :
public class TaskAssigneeEventListener implements EventListener {
...
@Override
public void notify(EventListenerExecution execution) throws Exception {
TaskService taskService = processEngine.getTaskService();
Task task =
taskService.createTaskQuery().processInstanceId(execution.getProcessInstance().getId()).uniqueResult();
if (task == null) {
logger.warn("No task found for ProcessInstance {}",
execution.getProcessInstance().getId());
} else {
logger.trace("task name {} ; assignee ",
task.getName(),task.getAssignee());
execution.createVariable("MyLastTaskAssignee", task.getAssignee());
}
}
}
Second : I want to retreive that value into an assignment handler to assign that task to
that user :
public class MyAssignementHandler implements AssignmentHandler {
//Field I want to inject from my process
private String previousUserId;
@Override
public void assign(Assignable assignable, OpenExecution execution) throws Exception
{
logger.trace("Value of previousUserId {} ", previousUserId);
if (previousUserId != null) {
assignable.setAssignee(previousUserId);
} else {
logger.warn("No assignee from the last task !!");
}
}
}
My tasks :
<task assignee="john" g="174,75,92,52"
name="taskUser">
<on event="end">
<event-listener expr="#{taskAssigneeEventListener}">
</event-listener>
</on>
<transition name="to taskManager" to="taskManager"
g="-126,-24" />
</task>
<task g="337,173,92,52" name="taskManager">
<assignment-handler expr="#{myAssignementHandler}">
<field name="previousUserId">
<object
expr="#{variables['MyLastTaskAssignee'}"/>
</field>
</assignment-handler>
<transition name="to end1" to="end1" g="-65,-24"
/>
</task>
Is it better to understand my need ?
Regards
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/546401#546401]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]