7 Replies Latest reply on Jan 21, 2008 7:41 AM by Ronald van Kuijk

    process variables - how to acces

    Tina Kleb Newbie

      Hi @all,

      I am confused in using "process variables":

      I have a processdefinition.xml which calls an ActionHandler when leaving a node.
      Within this ActionHandler I need the value of an input field from a form(xhtml) which belongs to processdefinition.xml.
      -> The form includes an input type 'date' its value I need within the ActionHandler.
      So I am having the following questions:
      1. Is 'date' a process variable?
      2. How to acces the value of 'date' within the ActionHandler?

      Thx for help,
      Tina

        • 1. Re: process variables - how to acces
          JeanDenis Bertron Newbie

          public class InitMyActionHandler implements ActionHandler {

          public void execute(ExecutionContext executionContext) throws Exception {

          executionContext.getContextInstance().setVariable("data", "value");

          }


          • 2. Re: process variables - how to acces
            Tina Kleb Newbie

            Thanks for your answer!

            But doesn't setVariable("data", "value") store the variable into the database?
            I am looking for how to get the value of the variable in the ActionHandler.
            So when the xhtml-form asks for the date like this:

            <jbpm:datacell>
             <f:facet name="header">
             <h:outputText value="Data"/>
             </f:facet>
             <h:inputText value="#{var['Data]}" />
             </jbpm:datacell>
            


            and the ActionHandler will store the variable and its value via:
             executionContext.getContextInstance().setVariable("data", "value");
            


            I need a variable declared in the ActionHandler called
            String data;

            and the processdefinition-file has to pass the value of Data to the ActionHandler - correct?
            But how to pass it?

            Cheers,
            Tina

            • 3. Re: process variables - how to acces
              Ronald van Kuijk Master

               


              I need a variable declared in the ActionHandler called
              String data;


              Have you tried looking at the docs?

              and the processdefinition-file has to pass the value of Data to the ActionHandler - correct?
              But how to pass it?

              Have you tried searching the forum (e.g. with google)

              Regards,



              • 4. Re: process variables - how to acces
                Tina Kleb Newbie

                Yes, I did...
                I found the following not meaningful article:
                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=127575

                So what means

                you have to store the variables in the process instance somehow

                When not knowing how to do something somehow is not helpful.


                Thx Tina

                • 5. Re: process variables - how to acces
                  Michael Wohlfart Expert

                  Hey,
                  are you complaining about my post? ;-)

                  with 'somehow' I ment to use any of the following methods:

                  ExecutionContext.setVariable(name, value)
                  TaskInstance.setVariableLocally(name, value) // inherited from VariableContainer
                  ContextInstance.createVariable(key, object, ooken);
                  


                  as far as i understand setVariableLocally() creates a variable only visible
                  in the task instance, but i am still new to jBPM and try to figure out things...

                  Regards

                  • 6. Re: process variables - how to acces
                    Tina Kleb Newbie

                    I am not complaining because your help is friendly. But as I said to say somehow is not helpful when user reading this article want to know how it works.

                    ExecutionContext.setVariable(name, value)
                    TaskInstance.setVariableLocally(name, value) // inherited from VariableContainer
                    ContextInstance.createVariable(key, object, ooken);

                    is only usable in a java-file, e. g. an ActionHandler - right?

                    I am looking for the way to make the value accessable for the java-file because there is a xhtml-form belonging to my processdefinition which gets input from a user and this input I need accessable in the java-file.

                    Do you know how this works?

                    Cheers Tina

                    • 7. Re: process variables - how to acces
                      Ronald van Kuijk Master

                      Tina,

                      If you want to know in detail how it works, look at the sourcecode of jbpm. Look at the testcases etc...etc...etc.. so much to learn from those.

                      The example in the link you post could be augmented with using the EL parser in the actionhandler on the value of the 'text' variable and not use the value directly. But there are some other posts on how to statically (designtime) set a variable from a processdefinition. Using actionhandlers currently is the way to go.