5 Replies Latest reply on Sep 20, 2005 6:58 AM by Thomas Sandor

    adding a variable at runtime

    Thomas Sandor Newbie


      Can anybody help me, how I can create a variable for a node at runtime?
      Do I have to create a contextVariable and a VariableAccess for each of my TaskNodes? I observed JpdlXmlReader but I found that only a variableAccess List can be added to the node's TaskController. How to specify my variable type (to create it as a Long, Date, Boolean, etc.)?

      What I'd like to do is to create e.g. a DATE type variable, and have it access with read/write from each of my taskNodes.

      How can I do that?


        • 1. Re: adding a variable at runtime
          Thomas Sandor Newbie

          It seems to me, that in jBPM2.0 there was a chance to specify a variable type with the

          syntax in the forms.xml. Or it seems in JPDL v2.0 there was a
           <variable .../>
          entry, with which I guess the variable Object type could be set at the process definition level.

          Do we have any workaround in jBPM 3.0? How to set variable object type at process definition level?


          • 2. Re: adding a variable at runtime
            Ronald van Kuijk Master

            these are two different questions.

            Answer 1:
            If you want to change the process definition, use a low level api. If you just want to add a variable to the running process instance, just use the normal update function you would use in e.g. an actionhandler. If you choose a name that is not used yet, the variable is created. You can try this e.g. in the monitor part of the webapp

            Answer 2:

            • 3. Re: adding a variable at runtime
              Thomas Sandor Newbie

              Thanks for the input. My problem is the same with the use of ActionHandler. In the processdefinition.xml you have no chance to specify preferred java object type for a variable (- nor to set description, that comes from TaskFormParameter) - that would be created when contextInstance returns with a null object, because of not founding a VariableInstance for the new varible. What's more, I have seen no test pages or testcases for defining a non-string variable.

              I've found entries in JIRA, that will handle types in a future release.


              • 4. Re: adding a variable at runtime
                Tom Baeyens Master

                did you check out the jbpm.varmapping.properties configuration file ? that allows you to configure the way that jbpm stores objects in the database on a jbpm level.

                or do you have a good motivation to configure how jbpm variables are persisted on a process level ?

                regards, tom.

                • 5. Re: adding a variable at runtime
                  Thomas Sandor Newbie


                  I looked at the JIRA, and voted for some issues regarding this feature. But finally I added a "className" and "description" attribute to the JpdlXmlReader, VariableAccess and TaskFormParameter, so this way I can add className-specific SpringMVC binders to the web page form, and evalute className-type objects. At submit, TaskFormParameter.value objects are stored properly by jBPM with variableInstances If you're interested in the modifications I made, I can send you diffs.