4 Replies Latest reply: Oct 9, 2012 7:59 AM by shashikala gonchigar RSS

jBPM WorkItemHandler problem: when Object is passed as param it's transformed to String.

Adam Bach Novice

Hi,

 

I'm passing an object of type Task to WorkItemHandler implementation and it lands in params map as after invoking toString method on my obejct.

WID definition:

import org.drools.process.core.datatype.impl.type.StringDataType;

import org.drools.process.core.datatype.impl.type.FloatDataType;

import org.drools.process.core.datatype.impl.type.ObjectDataType;

[

  // the CreateProject work item

  [

    "name" : "TaskTime",

    "parameters" : [

      "host" : new StringDataType(),

      "task" : new ObjectDataType(),

      "date" : new ObjectDataType(),

      "time" : new FloatDataType(),

    ],

    "displayName" : "TaskTime",

    "icon" : "icons/taskTime.png"

  ]

]

 

When I double click on my domain specific node on designer I get a window where I can provide values for parameters. So for task param I have given #{taskObj} and instead of an actual object I have received a String version of this object. The workaround is to explicitly map this param in properties view, but the idea was to give users UI for setting those values in more pleasent way.

 

ANOTHER problem is that when I set some values to my custom node than Properties view is not changing accorgingly to my my node type. Meannig when I click on some node than the Properties view is updated to show those props. Than when I click to my TaskTime node than Properties view has only those props which ware available for previous node, and if some props are common for both node than values for tham are updated with ne values. So when I click on my TaskTime node I can see the host,task,date,time properties, nor I can see on Entry and on Exit action properties. Furthermore If previosus node had such properties than I can see them for TaskTime node but when I update them than they are updated for that previosud node.

 

Can someone confirm those issues? Any help on workarounds?

  • 1. Re: jBPM WorkItemHandler problem: when Object is passed as param it's transformed to String.
    annah Newbie

    Hi Adam!

     

     

    I had the same problem with our custom tasks, and found out that there is an unecpected editor behaviour when saving&reading a BPMN model. As you can see in Properties view, the editor uses XStream to serialize objects, and it all works until you save your model. But when you click Save, the object is saved to file using toString method instead of using XStream. Also when reading from the model, it is read as string, instead of deserializing the object. As a consequence you will always get a string when calling work.getParameter("myParameter"). I noticed this behaviour not only for Object types, but for every data type (including Integer, Float etc. which should be supported according to specification).

    I don't know if this is a bug or it should really work this way.... unfortunately I didn't get any answer on this forum when I raised this question a month ago

     

    I solved this problem by serializing/deserializing the object myself, using:

    - to save parameter to workitem: work.setParameter("myParameter", xstream.toXML(data));

    - to read from work item: (My_Object) xstream.fromXML((String) workItem.getParameter("myParameter"));

     

    Hope this helps.

     

    I also noticed the delay probleim with Properties view, but haven't tried to solve it.

  • 2. Re: jBPM WorkItemHandler problem: when Object is passed as param it's transformed to String.
    Adam Bach Novice

    Are You refering to my problem with passing parameter or Properties editor? If You are saying aboute passing ObjectParams than as I have mentioned above igf You pass a para using parameter mapping than it works fine and is passed as object. it only breaks when you pass param as #{processVariable} in window which popsup when You doubleclick custom node.

  • 3. Re: jBPM WorkItemHandler problem: when Object is passed as param it's transformed to String.
    annah Newbie

    I'm talking about your problem with a custom popup editor, which uses workItem.put(name, value) to pass a parameter, which then gets serialized to your diagram's xml file.

    Parameters that you pass directly into a knowledge session are of course passed correctly because they newer get serialized.

  • 4. Re: jBPM WorkItemHandler problem: when Object is passed as param it's transformed to String.
    shashikala gonchigar Newbie

    THis is my wid file here i am using file to upload from the form but in workitem i am getting String type, how we solve this problem