7 Replies Latest reply on Jul 21, 2006 6:00 PM by kukeltje

    Inputting context variables to actions

    asimpson

      I am trying to use jpdl to pass context variables into actions called by a node. I know it is possible to call the variables from the controller using the context instance but I would like to be able to see the variables used by an action at the process definition level. Is there any way to do this?

      <action class="com.sample.action.MessageHandler">
       (specify variable input here)
      </action>
      



        • 1. Re: Inputting context variables to actions
          kukeltje

          you can specify variable names there and pass the names to the acion (see the docs and examples on how to do this). The action can then retrieve the variable names and use it to retrieve the values in the actionhandler. What I created is something like this:

          <action class="com.sample.action.MessageHandler">
           <message>bla, bla, bla text</message>
           <recipient>proc_var</recipient>
           <initiator/>
          </action>
          


          The 'message' is static and taken as a string by the actionhandler. The recipient points to a process variable which is to be used by this generic messagehandler and the 'initiator' is a direct reference to a process variable.

          hth

          • 2. Re: Inputting context variables to actions

            HOw do we receive these variables in the class?
            I am attempting to pass the initiator user to the class, to call the db.

            so I can test it like so

            System.out.println("Initiator is:"+initiator);

            Have looked around but found nothing in the docs or other yet.

            Thanks,
            James Ratcliff

            • 3. Re: Inputting context variables to actions
              kukeltje

              Come on James, you can do better than that. There is more info on this in the docs and the forum. The (wrong) assumption is that these are process variable names directly and will be filled by the engine. They aren't. If you have a variable in the actionhandler (not the process!!!) the variable is filled with the text within the tag (so the variable message in the actionhandler will get the value 'bla, bla, bla text')

              If you want it to 'indicate' a variable, use the value of the variable as the name of a process variable and use the normal means to get it (the context).

              • 4. Re: Inputting context variables to actions

                I looked around, all I find is stuff like this:
                http://www.jboss.org/index.html?module=bb&op=viewtopic&t=82665

                and Ch 10 about context variables...

                I understand that maybe I could pass a simple variable like this, but I need to get the swimlane user.

                Can I just directly ask for the swimlane initiator in some way? I have been searching the forums and the web, but it returns too many results for swimlane itself to make the searches useful... this was the post closest in relation to my issue.

                James Ratcliff

                • 5. Re: Inputting context variables to actions
                  kukeltje

                  James, one tip: the search in the forum is an OR so you should put an AND between it, or use the other radiobutton.

                  Second tip: Look at the testcases. There are lots, and prove to be a valuable source of information (not documenation if you followed the 'other' thread ;-)

                  You will find things like

                   ProcessInstance processInstance = new ProcessInstance(processDefinition);
                   processInstance.signal();
                  
                   TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
                   TaskInstance changeNappy = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
                   SwimlaneInstance stalker = taskMgmtInstance.getSwimlaneInstance("stalker");
                   assertEquals("me", stalker.getActorId());
                   assertEquals("me", changeNappy.getActorId())
                  
                  


                  The apidocs is also a valuable source of information



                  • 6. Re: Inputting context variables to actions

                    Just found it under the Swimlanetest right before I read this, thanks,
                    Yeah I keep forgetting the "and" option and getting way too many results...

                    James Ratcliff

                    • 7. Re: Inputting context variables to actions
                      kukeltje

                      :-)