5 Replies Latest reply on Aug 22, 2006 10:33 AM by Tom Baeyens

    JSF EL - Cant Pass parameters

    falazar Novice

      I am having a problem passing parameters in the JSF file

      I am looping through all process definitions, and trying to then call a function that can return the # of instances of that process. But its not working. There doesnt appear to be any way to pass a parameter back into the bean from the jsf page.


       <c:forEach var="processDefinition" items="#{participantBean.allProcessDefinitions}">
       <tr class="normal" onmouseover="this.className='hovered';" onmouseout="this.className='normal';" onclick="document.all['newExe#{processDefinition.id}\'].click()">
       <td class="selectable"><h:outputText value="#{processDefinition.name}" /> (<h:outputText value="#{processDefinition.id}" />) </td>
       <td class="selectable"><h:outputText value="#{processDefinition.version}" /></td>
       <td class="selectable">
      
      PROBLEM ON NEXT LINE
      <h:outputText value="#{participantBean.allProcessInstances(processDefinition.id)}" /> </td>
       <td class="selectable">
       <h:commandLink action="#{participantBean.startNewProcessInstance}" id="newExe#{processDefinition.id}">
       <f:param name="processDefinitionId" value="#{processDefinition.id}"/>
       Start It!
       </h:commandLink>
       </td>
       </tr>
       </c:forEach>
      


      // hmm count all active processes instead?
       // first get count of all processes here, then try it in the webpage, then return list if needed
       //public int getAllProcessInstances(long processDefinitionId)
       public String getAllProcessInstances()
       {
       //return "12";
       //System.out.println("PID:"+PID);
      
       return Integer.toString(jbpmBean.getJbpmContext().getGraphSession().findProcessInstances(109).size());
       //return Integer.toString(jbpmBean.getJbpmContext().getGraphSession().findProcessInstances(processDefinitionId).size());
       }
      


        • 1. Re: JSF EL - Cant Pass parameters
          Ronald van Kuijk Master

          James,

          This is JSF stuff and hs nothing to do with jBPM. If it is possible in jsf it is possible here.

          Datatables have some knowledge on the record you are working on, so these might help (where did I read this message before and responded the same... I have a deja-vu I think)

          Maybe you could make a hashmap and retrieve it based on the key (which can be the processid. This means that you have to extend the participantbean.

          • 2. Re: JSF EL - Cant Pass parameters
            Tom Baeyens Master

            afaik, passing parameters in jsf expressions is not yet supported.

            • 3. Re: JSF EL - Cant Pass parameters
              falazar Novice

              Hmm ok.

              Well I found one way to do it that got it working, I can show every version of the processdefinitions, and how many instances there are in it.

              What forum are we discussing web console issues? As I work on teh web app interface I would like to be able to show my findings and ask questions there.... I was looking through the faces mailing list as well.. but they didnt know offhand.

              Solution:
              The loop needs to be a ui:repeat instead of a forEach, and you must create a binding variable, that will set the variable for each spot in the loop, and you can access it in the bean.

               <ui:repeat var="processDefinition" value="#{participantBean.allProcessDefinitions}">
               <tr class="normal" onmouseover="this.className='hovered';" onmouseout="this.className='normal';" onclick="document.all['newExe#{processDefinition.id}\'].click()">
               <td class="selectable"><h:outputText value="#{processDefinition.name}" /> (<h:outputText value="#{processDefinition.id}" />) </td>
               <td class="selectable"><h:outputText value="#{processDefinition.version}" /></td>
              
               <td class="selectable">
               <h:outputText binding="#{participantBean.textElement}" value="">
               <f:attribute name="text" value="#{processDefinition.id}" />
               </h:outputText>
               <!-- The below function is called with the above parameter. -->
               <h:outputText value="#{participantBean.allProcessInstances}" />
               </td>
              
               <td class="selectable">
               <h:commandLink action="#{participantBean.startNewProcessInstance}" id="newExe#{processDefinition.id}">
               <f:param name="processDefinitionId" value="#{processDefinition.id}"/>
               Start It!
               </h:commandLink>
               </td>
               </tr>
               </ui:repeat>


              import javax.faces.component.html.HtmlOutputText;
              
               private HtmlOutputText textElement;
              
               // Count all process instances for this definition
               public String getAllProcessInstances()
               {
               // This text value is defined in the binding in the home.xhtml file
               long PID = ((Long)getTextElement().getAttributes().get("text")).longValue();
               return Integer.toString(jbpmBean.getJbpmContext().getGraphSession().findProcessInstances(PID).size());
               }
              
               public HtmlOutputText getTextElement() {
               return textElement;
               }
              
               public void setTextElement(HtmlOutputText textElement) {
               this.textElement = textElement;
               }


              The main part here is the getAllProcessInstances() method, which needs the processDefinition.id (PID) value to be passed in from the web form. With that we can return and display the number of instances there are for each processDefition version.

              James

              • 5. Re: JSF EL - Cant Pass parameters
                Tom Baeyens Master

                then the trick with the wrapper bean seems much more elegant to me.