7 Replies Latest reply on Nov 19, 2013 11:18 PM by mdegan

    How add a form to human task

    stellina_rosa

      I am trying to understand in what way I can add a form to my human tasks or a form for start a process; I have read this post: http://community.jboss.org/people/bpmn2user/blog/2011/02/27/helloprocess-example-using-jbpm5-eclipse-plug-in

      and so I understand that I must create a .ftl file for any form that I need and then I must create a jar to add in jboss/server/default/lib. After I need a java class to start the process (like the HelloProcessTest.java in the example).

      I can't understand one thing: the ONLY way to see my form is to use Guvnor? If I need a form to complete a human task, the only way to use it is to create a ftl file, add it to guvnor, build it in guvnor and then open the console?

      another thing that I can't understand is: in this video http://people.redhat.com/kverlaen/jBPM5-guvnor-integration.swf is importend only the .bpmn file, the .ftl file and the image, so I can't understand if the class HelloProcessTest is necessary! when I must use this class??

      sorry.. I'm confused!

      thank you very much

        • 1. How add a form to human task
          melc

          Hello,

          In order to have a form for a human task you can use three methods,

           

          1. You can use the default ftl functionality from the console. As you have realised it is necessary to upload the ftl file to guvnor, if you are going to use the console, because the console gets the form from the gwt-server-console which renders the form based on the ftl found in guvnor.

           

          2. You can use the default ftl functionality with your own application comunicating with gwt-console-server (as the console does) through the REST API of gwt-console-server. In this case you also need the ftl files in guvnor since the gwt-console-server will serve the rendered forms based on the ftl found in guvnor.

           

          3. You can use only api without using the ftl functionality and managing task services by your own. So when you have a task you may display your own gui and call relevant api in order to complete the task etc.  (see  http://community.jboss.org/people/bpmn2user/blog/2011/04/03/jbpm5-human-task-api-usage-example )

           

          In all cases there has to be a task service running.

          Generally guvnor is a repository and manager of your resources and rules logic, so if you use only the jbpm5 api then not only you don't need to use ftl files but you can also ignore guvnor completely. However you can certainly use guvnor from your api as well, as great repository, to build your knowledge base and use it for managing resources, having versions, building extra rules etc.

           

          I would appreciate any other ideas, comments etc thanks

          • 2. How add a form to human task
            stellina_rosa

            Thank you very much for your answer!

            It is important for me to know that guvnor is not necessary for adding form to my jbpm process! I'm going to try the example you linked me, so if I find any problem I can explain you!

            THANK YOU!!

            • 3. Re: How add a form to human task
              stellina_rosa

              I'm trying to run the example at http://community.jboss.org/people/bpmn2user/blog/2011/04/03/jbpm5-human-task-api-usage-example but when I run TaskServer.java I have this error:

               

               

              SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

              SLF4J: Defaulting to no-operation (NOP) logger implementation

              SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

              Hibernate: select task0_.id as col_0_0_, deadline1_.id as col_1_0_, deadline1_.deadline_date as col_2_0_ from Task task0_, Deadline deadline1_ where (deadline1_.id in (select startdeadl2_.id from Deadline startdeadl2_ where task0_.id=startdeadl2_.Deadlines_StartDeadLine_Id) or deadline1_.id in (select enddeadlin3_.id from Deadline enddeadlin3_ where task0_.id=enddeadlin3_.Deadlines_EndDeadLine_Id)) and deadline1_.escalated=0 order by deadline1_.deadline_date

              Hibernate: insert into OrganizationalEntity (DTYPE, id) values ('User', ?)

              Hibernate: insert into OrganizationalEntity (DTYPE, id) values ('User', ?)

              Hibernate: insert into OrganizationalEntity (DTYPE, id) values ('User', ?)

              Server started ...

              Exception in thread "Thread-4" java.lang.RuntimeException: Server Exception with class class org.jbpm.task.service.mina.MinaTaskServer using port 9123

                        at org.jbpm.task.service.mina.BaseMinaTaskServer.run(BaseMinaTaskServer.java:53)

                        at java.lang.Thread.run(Unknown Source)

              Caused by: java.net.BindException: Address already in use: bind

                        at sun.nio.ch.Net.bind(Native Method)

                        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)

                        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)

                        at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:251)

                        at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:48)

                        at org.apache.mina.core.polling.AbstractPollingIoAcceptor.registerHandles(AbstractPollingIoAcceptor.java:523)

                        at org.apache.mina.core.polling.AbstractPollingIoAcceptor.access$200(AbstractPollingIoAcceptor.java:65)

                        at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:407)

                        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                        ... 1 more

               

              I only understand that the port 9123 is already in use... but where??? Another doubt: where is the description of the gui in this example? I thought that if I don't use ftl file, I can define my gui with my favourite code (for example using swing or awt)... sorry but this example is not clear for me... if you have tried it, can you explain me the steps?

              I'm confused...!! please help me!


              • 4. How add a form to human task
                melc

                Hello,

                Indeed the port is in use try running netstat from console/command line to see the ports that are occupied etc. (Make sure that you are not running the task service via ant start.demo etc at the same time) . If you can't solve this just restart your machine

                 

                The idea of the example is that it shows how to see the available tasks through api and how to claim a task etc.... so once you have that you can create your ui with the api that claims a task and then shows a form with something, then that gui would have a button calling complete task if the task is completed and so on. If you would like to access the human task parameters i.e. content and actorid etc specified in eclipse then you can do that through the api. So imagine a case where you could do the following,

                1. a web page with a table (or a swing table or whatever) that displayes all tasks as retrieved from api

                2. a button to claim the task based on your credentials as retrieved by your web page

                3. call your own web form/web screen based on the task name (this is your own custom implementation, the task name will be on your web page table as retrieved via the api when you retrieved the tasks for this user's credentials etc) and use parameters passed via the content parameter of the human task node in eclipse etc All this info is available to you via the jbpm5 api

                4. have a button on your web form/web screen that completes the task by calling the api

                 

                Well that's the general idea.

                • 5. Re: How add a form to human task
                  mdegan

                  Hi Chris,

                   

                  I am following this structure that you have mentioned (using my own forms and application to manage form data). I am using API to fetch the human tasks and link my forms to it. However, I am trying to understand, how I can update process variables using my custom form data. The submit on my form calls my application action that saves the form data to database tables. Will I need to hard code something in my save action to identify node variable-process variable mapping for updating the value to the process variable. Any suggestions on this will be very helpful.

                   

                  Regards,

                  Manny

                  • 6. Re: How add a form to human task
                    melc

                    Hello Manny,

                    Whenever it is required to update process variables, you need to pass data back to the process when you complete a human task. So, when you retrieve the human tasks and display your own forms, after executing the logic, i.e. saving in the database, you also need to complete the human tasks in order for the process to proceed with its execution. On the completion of human tasks you can pass data, which you handle from your process and map the data to process variables.

                    • 7. Re: How add a form to human task
                      mdegan

                      Hi Chris,

                       

                      Thanks for the response. I did exactly that. I have written my own util that acts as the interface to transfer info from my application forms to the JBPM engine. As part of the util, I pass all the data from the form to the complete method for the task. That gets the data into the process engine and the variable are updated with the values. The only thing to keep in mind is to have the same field names in the forms as the process variables and it works.

                       

                      Regards,

                      Manny