[jboss-user] [JBoss jBPM] - Re: jpdl-3.2.Beta2: how to access variable from task form in

avbentem do-not-reply at jboss.com
Fri Feb 16 21:24:55 EST 2007


"kukeltje" wrote : does quantity have a value at all in your case? turn on debug to see if it does...
Yes, it gets a value in the first form (that is, of course: if I enter a value). Then it is retrieved for the next forms, but not explicitly (or not at all) retrieved when the form "Evaluate web order" immediately continues at the Fork, which after my changes moves on to the Decision before going to Ship Item... This might be fine, though I suddenly noticed a different token: "shipping" rather than root:

[GraphElement] event 'task-create' on 'Task(Create new web sale order)' for 'Token(/)'
  | [TaskInstanceVariableMap] fetched value 'null' for task variable 'quantity'
  | [TaskInstanceVariableMap] fetched value 'null' for task variable 'quantity'
  | [TaskInstanceVariableMap] fetched value 'null' for task variable 'quantity'
  | [TaskInstanceVariableMap] fetched value 'null' for task variable 'quantity'
  | [TaskInstanceVariableMap] setting task variable 'item' from 'null' to 'My test item'
  | [TaskInstanceVariableMap] setting task variable 'quantity' from 'null' to '1'
  | [TaskInstanceVariableMap] setting task variable 'address' from 'null' to 'My address'
  | [VariableContainer] create variable 'quantity' in 'TokenVariableMap3286a' with value '1'
  | [GraphElement] event 'task-end' on 'Task(Create new web sale order)' for 'Token(/)'
  | 
  | [GraphElement] event 'task-start' on 'Task(Evaluate web order)' for 'Token(/)'
  | [TaskInstanceVariableMap] fetched value '1' for task variable 'quantity'
  | [TaskInstanceVariableMap] fetched value '1' for task variable 'quantity'
  | [TaskInstanceVariableMap] Not changing value for variable quantity
  | [GraphElement] event 'task-end' on 'Task(Evaluate web order)' for 'Token(/)'
  | 
  | [GraphElement] event 'node-leave' on 'Fork(salefork)' for 'Token(/shipping)'
  | [GraphElement] event 'transition' on 'Transition(shipping)' for 'Token(/shipping)'
  | [GraphElement] event 'node-enter' on 'Decision(Fits in mailbox)' for 'Token(/shipping)'
  | [Decision] decision didn't select transition, taking default Transition(Yes)
  | [Decision] decision Fits in mailbox is taking 'Transition(Yes)'
  | [GraphElement] event 'node-leave' on 'Decision(Fits in mailbox)' for 'Token(/shipping)'
  | [GraphElement] event 'transition' on 'Transition(Yes)' for 'Token(/shipping)' 
  | [GraphElement] event 'node-enter' on 'Node(ship item)' for 'Token(/shipping)'
  | [ShipItem] ### grover now ships My test item to My address
  | [GraphElement] event 'node-leave' on 'Node(ship item)' for 'Token(/shipping)'

Above the log states "task variable". Maybe it's some other context? Earlier I tried using contextInstance.variables['quantity'] to no avail. http://docs.jboss.org/jbpm/v3/userguide/context.html does not give me other insight either, and Ship Item has no problem getting the variable in code, without caring for the token:

(String)contextInstance.getVariable("item")

However: I also noticed that in Wait for Money only the paymentId is fetched (not shown above, but no values for item, quantity and address are logged). So I guess only the variables that are listed in the form are actually retrieved; so then I should also somehow tell my Decision that some variables will be used? Do I need a Controller after all...?

Just for the sake of Google though I know it's going to be a long post: the above is logged when extending the websale example to the following processdefinition.xml, with no changes to the Java code:

<?xml version="1.0"?>
  | <process-definition name="websale" xmlns="urn:jbpm.org:jpdl-3.1">
  |   <swimlane name="buyer" />
  |   
  |   <swimlane name="salesman">
  |     <assignment actor-id="ernie" />
  |   </swimlane>
  |   
  |   <swimlane name="accountant">
  |     <assignment actor-id="bert" />
  |   </swimlane>
  |   
  |   <swimlane name="shipper">
  |     <assignment actor-id="grover" />
  |   </swimlane>
  |  
  |   <start-state name="Create new web sale order">
  |     <task swimlane="buyer" />
  |     <transition to="Evaluate web order" />
  |   </start-state>
  |   
  |   <task-node name="Evaluate web order">
  |     <task swimlane="salesman">
  |       <timer duedate="20 seconds" repeat="10 seconds">
  |         <action class="org.jbpm.websale.RemindActor">
  |           <swimlaneName>salesman</swimlaneName>
  |         </action>
  |       </timer>
  |     </task>
  |     <transition name="OK" to="salefork" />
  |     <transition name="More info needed" to="Fix web order data" />
  |   </task-node>
  | 
  |   <task-node name="Fix web order data">
  |     <task swimlane="buyer" />
  |     <transition to="Evaluate web order" />
  |   </task-node>
  | 
  |   <fork name="salefork">
  |     <transition name="payment"  to="Wait for money" />
  |     <transition name="shipping" to="Fits in mailbox" />
  |   </fork>  
  |   
  |   <task-node name="Wait for money">
  |     <task swimlane="accountant" />
  |     <transition to="update books" />
  |   </task-node>
  |   
  |   <node name="update books">
  |     <action class="org.jbpm.websale.UpdateBooks">
  |       <msg>accountancy application is now informed of the payment</msg>
  |     </action>
  |     <transition to="salejoin" />
  |   </node>
  |   
  |   <decision name="Fits in mailbox">
  |     <transition name="Yes" to="ship item">
  |       <condition expression='#{quantity==1}'/>
  |     </transition>
  |     <transition name="No" to="Inform customer">
  |       <condition expression='#{quantity!=1}'/>
  |     </transition>
  |   </decision>
  | 
  |   <task-node name="Inform customer">
  |     <task name="Call customer"></task>
  |     <transition name="Customer informed" to="ship item"></transition>
  |   </task-node>
  | 
  |   <node name="ship item">
  |     <action class="org.jbpm.websale.ShipItem">
  |       <swimlaneName>shipper</swimlaneName>
  |       <msg>${shipper} now ships ${item} to ${address}</msg>
  |     </action>
  |     <transition to="salejoin" />
  |   </node>
  |   
  |   <join name="salejoin">
  |     <transition to="end" />
  |   </join>  
  | 
  |   <end-state name="end" />
  | </process-definition>
...and gpd.xml:
<?xml version="1.0" encoding="UTF-8"?>
  | <process-diagram name="websale" width="566" height="541">
  |   <node name="Create new web sale order" x="250" y="50" width="200" height="40">
  |     <transition>
  |       <label x="5" y="-10"/>
  |     </transition>
  |   </node>
  |   <node name="Evaluate web order" x="280" y="125" width="140" height="40">
  |     <transition name="OK">
  |       <label x="9" y="-10"/>
  |     </transition>
  |     <transition name="More info needed">
  |       <label x="-44" y="-18"/>
  |       <bendpoint w1="-114" h1="-35" w2="116" h2="-35"/>
  |     </transition>
  |   </node>
  |   <node name="Fix web order data" x="50" y="125" width="140" height="40">
  |     <transition>
  |       <label x="5" y="-10"/>
  |       <bendpoint w1="109" h1="32" w2="-121" h2="32"/>
  |     </transition>
  |   </node>
  |   <node name="salefork" x="250" y="200" width="200" height="25">
  |     <transition name="payment">
  |       <label x="12" y="-18"/>
  |       <bendpoint w1="145" h1="31" w2="0" h2="-52"/>
  |     </transition>
  |     <transition name="shipping">
  |       <label x="10" y="10"/>
  |       <bendpoint w1="-126" h1="4" w2="14" h2="-51"/>
  |     </transition>
  |   </node>
  |   <node name="Wait for money" x="425" y="275" width="140" height="40">
  |     <transition>
  |       <label x="5" y="-10"/>
  |     </transition>
  |   </node>
  |   <node name="update books" x="425" y="350" width="140" height="40">
  |     <transition>
  |       <label x="5" y="-10"/>
  |       <bendpoint w1="-1" h1="34" w2="144" h2="-33"/>
  |     </transition>
  |   </node>
  |   <node name="Fits in mailbox" x="140" y="247" width="140" height="40">
  |     <transition name="Yes">
  |       <label x="5" y="-10"/>
  |     </transition>
  |     <transition name="No">
  |       <label x="5" y="-14"/>
  |       <bendpoint w1="-117" h1="1" w2="17" h2="-46"/>
  |     </transition>
  |   </node>
  |   <node name="Inform customer" x="6" y="294" width="140" height="40">
  |     <transition name="Customer informed">
  |       <label x="-74" y="6"/>
  |       <bendpoint w1="21" h1="51" w2="-116" h2="0"/>
  |     </transition>
  |   </node>
  |   <node name="ship item" x="143" y="345" width="140" height="40">
  |     <transition>
  |       <label x="5" y="-10"/>
  |       <bendpoint w1="30" h1="49" w2="-179" h2="1"/>
  |     </transition>
  |   </node>
  |   <node name="salejoin" x="250" y="425" width="200" height="25">
  |     <transition>
  |       <label x="5" y="-10"/>
  |     </transition>
  |   </node>
  |   <node name="end" x="280" y="500" width="140" height="40"/>
  | </process-diagram>
...and forms.xml:
<?xml version="1.0" encoding="UTF-8"?>
  | <forms>
  |   <form task="Create new web sale order" form="form.create.xhtml"/>
  |   <form task="Evaluate web order" form="form.evaluate.xhtml"/>
  |   <form task="Fix web order data" form="form.fix.xhtml"/>
  |   <form task="Wait for money" form="form.money.xhtml"/>
  |   <form task="Call customer" form="form.callcustomer.xhtml"/>
  | </forms>
...and form.callcustomer.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  |  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
  | <html xmlns="http://www.w3.org/1999/xhtml"
  |       xmlns:ui="http://java.sun.com/jsf/facelets"
  |       xmlns:c="http://java.sun.com/jstl/core"
  |       xmlns:h="http://java.sun.com/jsf/html"
  |       xmlns:f="http://java.sun.com/jsf/core"
  |       xmlns:tf="http://jbpm.org/jsf/tf"
  |       xmlns:jbpm="http://jbpm.org/jsf">
  |   <ui:component>
  |     <jbpm:dataform>
  |       <f:facet name="header">
  |         <h:outputText value="#{taskName}"/>
  |       </f:facet>
  |       <jbpm:datacell>
  |         <f:facet name="header">
  |             <h:outputText value="Informed whom"/>
  |         </f:facet>
  |       <h:inputText value="#{var['Informed whom']}" />
  |       </jbpm:datacell>
  |       <jbpm:datacell>
  |         <f:facet name="header">
  |             <h:outputText value="Delivery date"/>
  |         </f:facet>
  |       <h:inputText value="#{var['Delivery date']}" />
  |       </jbpm:datacell>
  |       <jbpm:datacell>
  |         <f:facet name="header">
  |           <h:outputText value="Actions"/>
  |         </f:facet>
  |         <tf:saveButton value="Save"/>
  |         <tf:cancelButton value="Cancel"/>
  |         <tf:transitionButton value="Save and Close"/>
  |       </jbpm:datacell>
  |     </jbpm:dataform>	
  |   </ui:component>
  | </html>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018020#4018020

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4018020



More information about the jboss-user mailing list