3 Replies Latest reply on Aug 10, 2011 12:25 PM by Maciej Swiderski

    External form rendering & accessing variables

    michael gantenbein Newbie

      Hi,

       

      Is it possible, to use external form rendering within jBPM5? I want to use existing JSF Pages to handle the human tasks.

       

      How can I get and set variables in my process programmatically?

       

      Thx.

        • 1. Re: External form rendering & accessing variables
          Maciej Swiderski Master

          In general, I would say yes, it is possible. But it all depends on what you would like to use as viewer. By default jBPM uses console and I think there is an eclipse test client for human tasks as well.

          So if you would like to have it integrated with console you should write plugin (if I recall properly implementation of FormDispatcherPlugin), something similar to the jbpm-gwt-form.

           

          But if you like to have it stand alone you would need to leverage both REST interface and Task Service client to connect to task service to operate on tasks. By default jBPM console is responsible for retrieving task forms, but if you like to use JSF for that, you won't need that any more.

           

          michael gantenbein wrote:

           

          How can I get and set variables in my process programmatically?

          To remotely access variables you could use REST interface, there is a process management facade that lets you, among other functions, set/get variables for particular process instance. For access it directly you should get variable scope from process instance and next add/retrieve variables out of it.

           

          HTH

          • 2. Re: External form rendering & accessing variables
            michael gantenbein Newbie

            Thank you for your response.

             

            I think, I can get the process scoped variables somehow like:

             

            ksession.getProcessInstance(selectedTask.getProcessInstanceId())).getVariable("payload");

             

            But how can I get variables in a different scope?

             

            I see, I can define variables with e.g. task scope in the designer, but how to access them? I think I could use that for my external form rendering. Means I read a task-scoped variable 'formName' to decide, which JSF page is associated with the current task.

             

            I don't want to use REST for that.

             

            Regards

            • 3. Re: External form rendering & accessing variables
              Maciej Swiderski Master

              michael gantenbein wrote:

               

              I see, I can define variables with e.g. task scope in the designer, but how to access them? I think I could use that for my external form rendering. Means I read a task-scoped variable 'formName' to decide, which JSF page is associated with the current task.

              That depends on what work item handler you use for human tasks. If you use default WSHumanTaskHandler, it checks if there is "Content" variable present for the task and if so it is used as task variables that are sent to TaskService as ContentData. If it does not exist it gets all properties available for the task instead.

              That means that all that data are stored in TaskService and its data base. So to get access to it, you would need to look the task up in TaskService and then access its content data.

               

              To be inline with BPMN2 spec user task (human task) should have rendering element (extension point in BPMN2) for rendering specific information. Because having form information as variable is more like injecting execution specific data as process data, which is not the best practice, in my opinion. Unfortunately looks like the only option for now.