2 Replies Latest reply on Apr 18, 2008 6:29 AM by Luis Miguel Rodriguez

    Referencing JSF components from Javascript in JPDL forms

    Luis Miguel Rodriguez Newbie

      Hi,

      I have modified a xhtml task form generated by the Graphical designer plugin in order to add a combobox component:

       <h:selectOneMenu onchange="updateTopic(this);" id="topicCombo" value="#{ChooseTopicBean.value}" styleClass="combobox">
       value="#{ChooseTopicBean.items}"/>
       </h:selectOneMenu>
       </jbpm:datacell>
      


      and defined apart a JS function called "updateTopic(ref)" which try to change the value of another jsf component when select any of the combobox's options, that is:

      <h:inputText id="inputTopic" value="#{var['topic']}" />
      


      I don't know how to reference the inputText from my JavaScript function since I've seen from the generated HTML page parsed by the browser that the components/forms IDs are generated dynamically:

      <input id="j_id197:inputTopic" type="text" name="j_id197:inputTopic" />
      


      So, I'll get an error if I try to reference as "document.getComponentById('inputTopic')".

      Where is the "j_id197" id name coming from? Is there any other way to reference jsf components from Javascript?

      Thanks in advance.

      Cheers.

        • 1. Re: Referencing JSF components from Javascript in JPDL forms
          Ronald van Kuijk Master

           

          Where is the "j_id197" id name coming from?
          JSF, it is the ID of the parent form element. Give the form element an explicit ID and you get something with this id as the prefix for the input element

          • 2. Re: Referencing JSF components from Javascript in JPDL forms
            Luis Miguel Rodriguez Newbie

            Ok, but I'm posting the issue in this forum because I'm trying to tweak the xhtml forms provided with jBPM console, that is:

            
            <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"
             xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
             >
            
             <ui:component>
            
             <jbpm:dataform>
            
             <f:facet name="header">
             <h:outputText value="#{taskName}"/>
             </f:facet>
            
             <jbpm:datacell>
             <f:facet name="header">
             <h:outputText value="New Topic name:"/>
             </f:facet>
            
             <h:selectOneMenu value="#{ChooseTopicBean.value}" styleClass="combobox">
             <a4j:support event="onchange" reRender="inputTopic" />
             <f:selectItems id="yourItemId" value="#{ChooseTopicBean.items}"/>
             </h:selectOneMenu>
             </jbpm:datacell>
            
             <!-- TASKFORM ROWS -->
             <jbpm:datacell>
             <f:facet name="header">
             <h:outputText id="out" value="Topic name:"/>
             </f:facet>
             <h:inputText id="inputTopic" value="#{ChooseTopicBean.value}" />
             </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="Configure SeedDiscovery" value="Configure SeedDiscovery"/>
             </jbpm:datacell>
            
             </jbpm:dataform>
            
             </ui:component>
             </html>
            


            as you can see, I have no <f:form> tag. I've tried with

            <ui:component id="myform">


            and

            <jbpm:dataform id="myform">


            but the latter turned out to be the data table. So, the html tags are generated automatically. How could I get my goal?

            BTW, where can I find the Tag library documentation of jBPM JSF tags?

            Cheers