9 Replies Latest reply on Oct 9, 2007 3:46 AM by kukeltje

    How to use hibernate session in jbpm xhtml files

    nicos109

      Hello,

      I'd like to use hibernate session attributes in jbpm xhtml files using taglibs.

      Thanks

        • 1. Re: How to use hibernate session in jbpm xhtml files
          kukeltje

          jbpm webconsole uses jsf so I'd assume you can use those in the same way you would in a normal hibernate/jsf way (not that I can describe that for you from my head, but I think you get the picture)

          If you have a more detailed example of what you want, with a case that demonstrates this (maybe with errors) I'd be happy to have a more detailed look.

          • 2. Re: How to use hibernate session in jbpm xhtml files
            dleerob

            I'm not sure how it's done using JSF, but I make use of my own tags to access info from jbpm libraries/database. Here's an example of how I do it:

            /**
             * This tag will create an html dropdown list of all the current
             * groups within the jbpm database, where the value and label of
             * each option is the group name.
             *
             * @jsp.tag name="groupSelectBox" bodycontent="empty"
             */
            public class GroupListTag extends BaseTag {
            
             private static final long serialVersionUID = 1L;
             protected String name = null;
             protected String type = null;
            
             /**
             *
             */
             protected void execute() throws Exception {
             JbpmContext jbpmContext = null;
             try {
             jbpmContext = StaticVariables.jbpmConfiguration.createJbpmContext();
             //get list of jbpm groups
             Session session = jbpmContext.getSession();
             String hibernateQuery = "from org.jbpm.identity.Group g";
             if (type != null) {
             //we then only want groups with the given group type.
             hibernateQuery += " where g.type = '"+type+"'";
             }
             List jbpmGroupList = session.createQuery(hibernateQuery).list();
             //create html drop down list of desired groups.
             jspOut.println("<SELECT name='"+name+"'>");
             jspOut.println("<OPTION value=''>-- Please Select --</OPTION>");
             for (int x = 0; x < jbpmGroupList.size(); x++) {
             Group group = (Group)jbpmGroupList.get(x);
             jspOut.println("<OPTION value='"+group.getName()+"'>"+group.getName()+"</OPTION>");
             }
             jspOut.println("</SELECT>");
             }
             catch (Exception e) {
             e.printStackTrace();
             }
             finally {
             jbpmContext.close();
             }
             }
            
             /**
             * Setter for name of the dropdown list.
             * @jsp.attribute required="true" rtexprvalue="true"
             */
             public void setName(String name) {
             this.name = name;
             }
            
             /**
             * Setter for the type of group.
             * @jsp.attribute required="false" rtexprvalue="true"
             */
             public void setType(String type) {
             this.type = type;
             }


            My .tld is auto generated, using the xdoclet tags you see above. Here's what it may look like:
            <taglib>
            
             <tlib-version>1.0</tlib-version>
             <jsp-version>1.2</jsp-version>
             <short-name>workflow</short-name>
            
             <description><![CDATA[Custom tag library for this application]]></description>
            
             <tag>
            
             <name>groupSelectBox</name>
             <tag-class>workflow.webapp.taglib.DepartmentListTag</tag-class>
            
             <attribute>
             <name>name</name>
             <required>true</required>
             <rtexprvalue>true</rtexprvalue>
            
             </attribute>
             <attribute>
             <name>type</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
            
             </attribute>
            
             </tag>
            </taglib>


            Finally, my JSP page that makes use of the tag:
            <workflow:groupSelectBox name="CostCentre" type="Cost Centre"/>


            Hope it gives you some ideas...

            • 3. Re: How to use hibernate session in jbpm xhtml files
              kukeltje

              looks about right... (cannot spot any immediate problems)... so what is the problem with this?

              • 4. Re: How to use hibernate session in jbpm xhtml files
                dleerob

                 

                looks about right... (cannot spot any immediate problems)... so what is the problem with this?
                Not sure if you were asking me this question? Anyway, If so, there's no problem with it...works perfectly for me...I was just posting what I did so maybe it could help Nicos109 out...

                • 5. Re: How to use hibernate session in jbpm xhtml files
                  kukeltje

                  aaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhh SORRY.....

                  I did not see there were two different posters....... hahahahahha.....

                  • 6. Re: How to use hibernate session in jbpm xhtml files
                    nicos109

                    ok but you're writing your own taglib, that's fine but I'd prefer not to do this but rather use the existing taglibs.
                    for example the combo box could be filled with a list object.
                    what I'd like to do is something like this :
                    <f:selectItems value=#{var['list']}>
                    or <f:selectItems value=${sessionScope['list']}>
                    what should I do in a JAVA action class to make this possible ?

                    • 7. Re: How to use hibernate session in jbpm xhtml files
                      kukeltje

                      search the forum.... has been discussed

                      • 8. Re: How to use hibernate session in jbpm xhtml files
                        nicos109

                        wow this is a smart answer, how about using google, too ?

                        • 9. Re: How to use hibernate session in jbpm xhtml files
                          kukeltje

                          it indeed is a smart answer, just like the post is on-topic ;-)