-
1. Re: passing data to AssignmentHandler best practice?
kukeltje Aug 31, 2006 6:40 PM (in response to jmjava)Yes, or retrieve them in a special assignmenthandler, or from your own database or in an actionhandler or whatever. It is indeed that simple. Great isn't it :-)
-
2. Re: passing data to AssignmentHandler best practice?
jmjava Aug 31, 2006 6:53 PM (in response to jmjava)thanks ron i am having trouble with the syntax:
taskInstance.setVariable("buyer", "cookiemonster");
taskInstance.setVariable("salesman", "ernie");
taskInstance.setVariable("accountant", "bert");
taskInstance.setVariable("shipper", "grover");
i want to be able to access these variables in script and i am trying:
<assignment expression="taskInstance.variables['salesman']" />
<assignment expression="taskInstance.variables['accountant']" />
<assignment expression="taskInstance.variables['shipper']" />
but i'm getting this error: couldn't resolve assignment expression 'taskInstance.variables['salesman']'
I have been reading the beanshell pdf put it's not helping much. any ideas? -
3. Re: passing data to AssignmentHandler best practice?
kukeltje Aug 31, 2006 6:58 PM (in response to jmjava)Please use the [ c o d e ] tags without the spaces around your xml. Use preview to see the result.
You cannot use beanshell in the expression. Look at the jbpm docs and more important the testcases to see how you should use this. -
4. Re: passing data to AssignmentHandler best practice?
jmjava Aug 31, 2006 7:29 PM (in response to jmjava)FWIW I got it:
Instead of hardcoding the assignment like in the base websale example i changed the process Defintion to be:<swimlane name="salesman"> <assignment actor-id="#{taskInstance.variables['salesman']}" /> </swimlane> <swimlane name="accountant"> <assignment actor-id="#{taskInstance.variables['accountant']}" /> </swimlane> <swimlane name="shipper"> <assignment actor-id="#{taskInstance.variables['shipper']}" /> </swimlane>
and after i create my processInstance i set the taskInstance variables in java code:
// create a new taskinstance for the start task TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); taskInstance.setVariable("buyer", "cookiemonster"); taskInstance.setVariable("salesman", "ernie"); taskInstance.setVariable("accountant", "bert"); taskInstance.setVariable("shipper", "grover");
this allows me to assign the swimlane actors via business logic instead of hardcoding them.
-jm -
5. Re: passing data to AssignmentHandler best practice?
stibrian Sep 5, 2006 5:16 PM (in response to jmjava)using the names of the swimlanes and a custom assignment class is another trick that works well for me.
Or using a "named user" that is stored in the process as a variable and then again using swimlane name as a key into which one you want - nearly no code, but nice flexibility.