2 Replies Latest reply on Oct 25, 2012 10:58 AM by rickylkl

    How to get variable from  WorkItemHandler class  ??

    rickylkl Newbie

      Hi forum,


      Anyone who can help or point me how can i GET THE VARIABLE THAT I INSERT IN SESSION or STARTPROCESS(processId, VARIABLE) ?


      I got c controller with this method :


      private void testDrlJbpm(Channel channel){

                          Map<String,Object> map = new HashMap<String,Object>();

                          map.put("channel", channel);


                          ksession.insert(channel);                                                  //          if there is a rule flow in workflow, need to insert obj to run rule

                          ksession.getWorkItemManager().registerWorkItemHandler("ShowRegPage", new RegistrationHandler());

                          ksession.getWorkItemManager().registerWorkItemHandler("ShowSubPage", new SubscribeHandler());

                          ksession.getWorkItemManager().registerWorkItemHandler("ShowPrintPage", new PrintPageHandler());

                          ProcessInstance processInstance = (ProcessInstance) ksession.startProcess("testflow-web", map);          //          passing map inside the process, and use kcontext.getvariable() to get obj on if else case




                          ksession.fireAllRules();                                                            // fire all rules if there is a rule flow



      AND i did this method in workItemHandler



                public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {





                          System.out.println("========= Executing registration =============" + workItem);


                          Map<String,Object> resultMap = new HashMap<String,Object>();

                          resultMap.put("reg", registration);

                          manager.completeWorkItem(workItem.getId(), resultMap);



      At last,

      i have attache the jpg of flow.


      I always get nothing ...


      I would like to get the varaible and do variable passing between the workItemHandler and from rules, is there any way i can follow ?? Please Thanks


      Thanks a lot to all.

      Please Help !!

        • 1. Re: How to get variable from  WorkItemHandler class  ??
          Esteban Aliverti Master

          Process variables are not automatically passed to your workItemHandlers. In the process you need to define the input and output parameters of the workItem (something like the input and output parameters of your workItem) and then you must do the mapping between the process variables and the workItem input parameters and between the workItem output parameters and the process variables again.


          Best Regards,

          1 of 1 people found this helpful
          • 2. Re: How to get variable from  WorkItemHandler class  ??
            rickylkl Newbie

            helo esteban,

                 First, thanks for quick response !! Is there any material or example to do input & output variable mapping ? I did try the basic mapping like string , integer , etc, it's work.

                 However, while i try to do mapping on the object / hashMap , it's not work. I have no idea why , could you help me more a bit on that. I define the bpmn by using eclipse drools+jbpm plugin. I try to do mapping like attach, but i fail to get this params on next node, please help me futher more much thanks !




            螢幕快照 2012-10-25 下午10.56.40.png