12 Replies Latest reply on Jun 18, 2007 6:09 AM by ambika devi

    JBPM JSF Integrartion

    ambika devi Newbie

      Hi

      I am a new bie to work in JBPM

      I am working in JBPM from past two months. There is a web
      application project been developed using JSF, Spring and Hibernate.

      Iam trying to show the workflow of that Project. I have tried with the
      simple appication using JBPM to show the workflow it is working properly.

      But know i am trying to call our own jsf pages when each and every task
      node is called.

      Please suggest me is there any possibility to do in this way.. i have
      gone through lots and lots forums and documents.

      Whenever i tried using to do with task node. Only default controller is working properly. Is it possible with custom controller to call the JSF Pages of my Web Application Project.

      If that is the case how to go about.

      I couldn't get anything. Kindly help and response my needful query.

      Thanks in advance.

      Ambika.

        • 1. Re: JBPM JSF Integrartion
          Ronald van Kuijk Master

          Options (in order of my preference)
          - use seam
          - build your own controller (see the default controler for an example)
          - build your own framework

          Ronald

          • 2. Re: JBPM JSF Integrartion
            ambika devi Newbie

            Hi Ronald

            Thanks for ur reply.

            I dont want to use seam.

            I want to know like, if i want to use my own controller then how to proceed with.

            Then what do u meant by my own framework, is it like to making my own JBPM framework in the sense to modify the existing JBPM war file.

            Kindly suggest or help me.

            Thanks,
            Ambika.

            • 3. Re: JBPM JSF Integrartion
              Ronald van Kuijk Master

               

              "ambika_devi" wrote:

              I want to know like, if i want to use my own controller then how to proceed with.

              That would cost me way to much time to tell you... sorry, but investigate first

              "ambika_devi" wrote:

              Then what do u meant by my own framework, is it like to making my own JBPM framework in the sense to modify the existing JBPM war file.


              Yes, just using the api at a low level, deciding what page to show in your own way

              • 4. Re: JBPM JSF Integrartion
                Roberto Alonso Ramos Zapata Newbie

                I don´t know with which version of JBPM are you working, but in the 3.1.4 there's a war file named jbpm.war
                That application was made with JSF using the myfaces 1.1.5 api. Take a look at that and you will find everything you need to get started.
                Plus, in the folder jbpm of the staters-kit under src/org/jbpm/webapp you can find the clases that they use on that aplication wich can be very helpful to learn how to integrate your application.

                hope that helps.

                I have a JSF application which uses JBPM.

                • 5. Re: JBPM JSF Integrartion
                  Ronald van Kuijk Master

                  for custom forms etc... I'd use jbpm 3.2

                  • 6. Re: JBPM JSF Integrartion
                    ambika devi Newbie

                    Thanks roccolocko

                    I am using the Jbpm Starters Kit 3.1.4 only.

                    Once i changed my jbpm.war file including my jsf pages and changed the faces config file and again i made a new jbpm.war and deployed in the server.

                    It had worked properly but in this way how can i integerate with jbpm. This is like i am changing the entire optimized JBPM framework right.

                    What do u specify like look after the classes in src/org/jbpm/webapp using this how can i integrate my web application with jbpm.

                    Pls Help and suggest me.

                    • 7. Re: JBPM JSF Integrartion
                      Roberto Alonso Ramos Zapata Newbie

                      One way to go its what you did, modify the jbpm.war and include your JSF files in there but then you will only be changing things all the time to fit your needs.

                      I thing the best way to do an integration is to generate your own war file (yourAplication.war) and communicate that application with the jbpm engine, remember that jbpm is not the jbpm.war, that is only a example of how you can make the jbpm work.

                      Once you deploy your own application on the deploy folder of the server, yor have access to everything on the jbpm engine, just by using the API.

                      You have everything there, so for example, if you have a button to save a task on your application, you only need a java class that uses the jbpm API to save the task, variables, and takes the transition you need it to take.

                      For example(this is what I use):

                      public void save(Hashtable taskVariables, String transition)
                       {
                       this.jbpmContext = JbpmConfiguration.getInstance().getCurrentJbpmContext();
                       this.taskMgmtSession = jbpmContext.getTaskMgmtSession();
                      
                       try
                       {
                       TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId);
                       System.out.println("ESTA ABIERTA???: " + jbpmContext.getSession().isOpen());
                      
                       if(taskVariables != null && taskVariables.size() > 0)
                       {
                       Iterator i = taskVariables.keySet().iterator();
                       while(i.hasNext()){
                       String key = (String)i.next();
                       Object value = taskVariables.get(key);
                       taskInstance.setVariable(key, value);
                       }
                       }
                       taskInstance.end(transition);
                      
                       jbpmContext.save(taskInstance);
                      
                       }
                       }
                      


                      Of course you need to import the correspondent packeges which in my case are:
                      import org.jbpm.JbpmConfiguration;
                      import org.jbpm.JbpmContext;
                      import org.jbpm.db.TaskMgmtSession;

                      Hope that helps.

                      • 8. Re: JBPM JSF Integrartion
                        ambika devi Newbie

                        You mean to say that each and every JSF pages in my web application to be changed to access the JBPM Engine and to be made as a war file then deployed in the server.

                        Can you pls tell me that my application to be deployed in jbpm server or in some other web server like Tomcat or JBoss etc...

                        You have also mentioned to include the java class code in the save button of my jsf page, in the java class code u r passing some arguments.

                        public void save(Hashtable taskVariables, String transition)
                        

                        where this arguments are coming from, where i dont have any taskvariables and transitions in my web application.

                        I think that we are using the taskvariables and transitions in JBPM right. So how do you want me to integrate these parameters into my own web application.

                        Then clear me with one thing like is it possible to access the jbpm database from my application, if that is the case then i have to specify the jbpm configuration file and everything, can u help me in the directory structure of the web application which is using jbpm.

                        Pls kindly help me and explain me clearly.




                        • 9. Re: JBPM JSF Integrartion
                          Ronald van Kuijk Master

                          I'd suggest you investigate how the jbpm webconsole does things. It will give you a clear understanding of how the api can be used in a webapp.

                          • 10. Re: JBPM JSF Integrartion
                            ambika devi Newbie

                            Hi roccolocko

                            Suggest and help me in the code which u have given to me..

                            Hi Ronald

                            JBPM Console is using some forms.xml and some .xhtml files..

                            Where by i couldn't understand completely with that.

                            If i am using the forms.xml and some xhtml files also it is not working

                            I couldn't view that in Jbpm Console process instance(http://localhost:8080/jbpm-console)

                            Thanks
                            Ambika

                            • 11. Re: JBPM JSF Integrartion
                              Ronald van Kuijk Master

                              hmmm..... that is the real simple part... forms.xml maps the plain xhtml (facelets based jsf pages) on tasks... remarkable you could not find that link from the examples

                              if it does not work, there is something wrong....

                              • 12. Re: JBPM JSF Integrartion
                                ambika devi Newbie

                                Hi roccolocko

                                Suggest and help me in the code which u have given to me..

                                Hi Ronald

                                I am using jbpm-jpdl-3.2.GA as my jboss jbpm runtime in eclipse.

                                I included the eclipse plugins which are inside the D:\jbpm-jpdl-3.2.GA\designer\eclipse\plugins into my eclipse.

                                Then i added task to the start state. In the advanced properties for task, i found
                                Due Date:
                                Blocking:
                                and Generate Form Button.

                                Clicking on the Generate Form Button i added the variables and i gave a file named "task.xhtml". once after doing this, i got the forms.xml and the task.xhtml inside my process dir.

                                
                                forms.xml
                                ------------
                                <?xml version="1.0" encoding="UTF-8"?>
                                
                                <forms>
                                 <form task="task" form="task.xhtml"/>
                                </forms>
                                
                                task.xhtml
                                ------------
                                
                                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
                                
                                <!-- the DOCTYPE means we are required to use html for a root element -->
                                <html xmlns="http://www.w3.org/1999/xhtml"
                                 xmlns:ui="http://java.sun.com/jsf/facelets"
                                 xmlns:c="http://java.sun.com/jstl/core"
                                 xmlns:h="http://java.sun.com/jsf/html"
                                 xmlns:f="http://java.sun.com/jsf/core"
                                 xmlns:tf="http://jbpm.org/jsf/tf"
                                 xmlns:jbpm="http://jbpm.org/jsf">
                                
                                 <ui:component>
                                
                                 <jbpm:dataform>
                                
                                 <f:facet name="header">
                                 <h:outputText value="#{taskName}"/>
                                 </f:facet>
                                
                                 <!-- TASKFORM ROWS -->
                                 <jbpm:datacell>
                                 <f:facet name="header">
                                 <h:outputText value="name"/>
                                 </f:facet>
                                 <h:inputText value="#{var['name']}" />
                                 </jbpm:datacell>
                                 <jbpm:datacell>
                                 <f:facet name="header">
                                 <h:outputText value="number"/>
                                 </f:facet>
                                 <h:inputText value="#{var['number']}" />
                                 </jbpm:datacell>
                                
                                 <jbpm:datacell>
                                 <f:facet name="header">
                                 <h:outputText value="Actions"/>
                                 </f:facet>
                                 <!-- TASKFORM BUTTONS -->
                                 <tf:saveButton value="Save"/>
                                 <tf:cancelButton value="Cancel"/>
                                 <tf:transitionButton transition="to_state" value="to_state"/>
                                 </jbpm:datacell>
                                
                                 </jbpm:dataform>
                                
                                 </ui:component>
                                
                                </html>
                                
                                
                                


                                Only by generating form, i couldn't get the variables in the jbpm-console.

                                If i am giving that variables in default controller only, the variables are displayed in the process instance otherwise not.

                                Then i deployed my process definition in the D:\jbpm-jpdl-3.2.GA\server

                                It is deployed sucessfully with that variables but i coudn't edit the value of the variable (Even if i am giving it in default controller) in Jbpm console.

                                Help me in the code and suggest which server to use and how to deploy.

                                Thanks
                                Ambika.