7 Replies Latest reply on Jun 20, 2007 9:43 AM by kukeltje

    How to access process variables?

    dabd

      I defined an action handler
      that tries to access a process variable like this:
      Integer quant = (Integer) executionContext.getContextInstance().getVariable("quant");

      But I get a null pointer exception.

      The variable "quant" was defined in the Form Controller of the process designer and I generated the form with the same tool.

      What am I missing?

      Thanks.

        • 1. Re: How to access process variables?
          fuligj

          Another question. How could I get a process variable ( for example var['quantity']) in an external web page?
          Thank You!

          • 2. Re: How to access process variables?
            cristian_e

            You can try executionContext.getVariable("quant") directly. At least this is the way we have worked with variables in ActionHandlers (with the appropriate cast). In our case the variables have been set programatically, but I think it's the same thing with your scenario.

            About fuligj's question, I'm not sure I understand what you mean. If you are asking about how to show this variable in a web page, all I can say is you have a million ways, where probably struts and JSF are the most popular.

            Hope it helps.

            • 3. Re: How to access process variables?
              fuligj

              I say thank you for it your answer. I believe it, you misunderstood a small one. I would like to attain the variables of the process, apart from a process from a web page. But in the external page, the var[] data map does not live. I think, this the taskInstanceBean's job. A solution would be needed for this problem.

              Thank You!

              • 4. Re: How to access process variables?

                Why don't you create a map of variables at your application context level and store it there.
                Moreover you can have this variable in an external database and create the hibernate mapping for it and make it accessible for all of your requirements

                • 5. Re: How to access process variables?
                  dabd

                   

                  "cristian_e" wrote:
                  You can try executionContext.getVariable("quant") directly. At least this is the way we have worked with variables in ActionHandlers (with the appropriate cast). In our case the variables have been set programatically, but I think it's the same thing with your scenario.

                  Hope it helps.


                  I think the reason I was getting a null pointer exception was that in the web console form I was clicking on the save button instead of the save & close button, so the process variable was not being updated. This form was generated by the gpd.

                  • 6. Re: How to access process variables?
                    fuligj

                    Because the data would turn up duplicated then.

                    • 7. Re: How to access process variables?
                      kukeltje

                      woooowwww .... lots of wrong assumptions here

                      pressing save does save the variables, just not make the task finish and the process take an transition

                      The taskinstancebean is for the console, but can be reused. If you want to combine data from your own system with processdata, you'll have to develop a small framework for it (e.g. MyTaskBean class) and use the jbpm api in there