7 Replies Latest reply on Dec 20, 2007 11:37 AM by pmuir

    Same element ID in many forms on the page

    vanyatka

      Hi,

      When I use the following form alone on the page everything is fine, but if put it into some iteration element, like rich:dataTable then #{tagHome.instance.name} varibale isn't initialised.

      Can anyone suggest what could be the matter?

      Any help is much appreciated,


      <a4j:form ajaxSubmit="true">
       <rich:panel>
       <h:panelGrid columns="2">
       <h:panelGroup>
       <h:inputText value="#{tagHome.instance.name}" id="suggestion" />
       <rich:suggestionbox for="suggestion"
       suggestionAction="#{tagHome.autocomplete}" var="tag"
       tokens="," width="200" height="100"
       frequency="1000"
       >
       <h:column>
       <h:outputText value="#{tag.name}" />
       </h:column>
       <h:column>
       <h:outputText value="#{tag.id}" />
       </h:column>
       </rich:suggestionbox>
      
       </h:panelGroup>
       <a4j:commandLink value="Add Tag" reRender="tagsPanel" action="#{tagHome.persist}">
       <a4j:actionparam name="cardID" value="#{card.id}"
       assignTo="#{tagHome.cardID}" />
       </a4j:commandLink>
       </h:panelGrid>
       </rich:panel>
       </a4j:form>
      


        • 1. Re: Same element ID in many forms on the page
          pmuir

          What does isn't initialised mean here?

          • 2. Re: Same element ID in many forms on the page
            vanyatka

            That in the action method it's value is null.

            • 3. Re: Same element ID in many forms on the page
              pmuir

              Can we see an example of it inside the iterator? i.e. post the xhtml including the iterator

              • 4. Re: Same element ID in many forms on the page
                vanyatka

                Here it is. Also, when more then one element in the list the suggestionBox stops working.

                <rich:dataTable id="cardList" var="card" value="#{cardList.resultList}"
                 rendered="#{not empty cardList.resultList}"
                 width="300px">
                
                 <h:column>
                 <f:facet name="header">Id</f:facet>
                 <h:outputText>#{card.id}</h:outputText>
                 </h:column>
                 <h:column>
                 <f:facet name="header">Name</f:facet>
                 <s:link id="card" value="#{card.name}" view="/card.xhtml"
                 propagation="">
                 <f:param name="cardId" value="#{card.id}" />
                 </s:link>
                 <rich:panel rendered="#{not empty card.tagLinks}" id="tagsPanel">
                 <h:outputText>Tags:</h:outputText>
                 <a4j:repeat id="detail" value="#{card.tagLinksAsList}" var="detail">
                 <h:outputText value="#{detail.tag.name} " />
                 </a4j:repeat>
                 <h:messages />
                 </rich:panel>
                
                 <h:form>
                 <rich:panel>
                 <h:panelGrid columns="2">
                 <h:panelGroup>
                 <h:inputText value="#{tagHome.instance.name}" id="suggestion" />
                 <rich:suggestionbox for="suggestion"
                 suggestionAction="#{tagHome.autocomplete}" var="tag"
                 tokens="," width="200" height="100"
                 frequency="1000"
                 >
                 <h:column>
                 <h:outputText value="#{tag.name}" />
                 </h:column>
                 <h:column>
                 <h:outputText value="#{tag.id}" />
                 </h:column>
                 </rich:suggestionbox>
                
                 </h:panelGroup>
                 <a4j:commandButton value="Add Tag" reRender="tagsPanel" action="#{tagHome.persist}">
                 <a4j:actionparam name="cardID" value="#{card.id}"
                 assignTo="#{tagHome.cardID}" />
                 </a4j:commandButton>
                 </h:panelGrid>
                 </rich:panel>
                 </h:form>
                
                 </h:column>
                 </rich:dataTable>


                • 5. Re: Same element ID in many forms on the page
                  pmuir

                  Well I guess that each row of the dataTable binds its inputText to #{tagHome.instance.name}, and so when you submit, you don't get the one you have used.

                  • 6. Re: Same element ID in many forms on the page
                    vanyatka

                    Shouldn't the used one belong to the form I'm sending? There are more than one form on the page, you don't mean each form should have own set of objects for binding its data, do you? =)

                    • 7. Re: Same element ID in many forms on the page
                      pmuir

                      Oh, I missed that. Then I'm at a loss, sorry.