6 Replies Latest reply on Mar 22, 2011 11:11 AM by Stefano C

    a4j:htmlCommandLink dynamic id not working

    Stefano C Newbie

      Hi all,

       

      i want to set the id on a link in a dataTable, because i want to set up a test and i need it.

       

      i've a rich:dataTable, the first column is a link to edit the element :

       

      <rich:column>
          <f:facet name="header">
               <h:outputText value="Username" />
          </f:facet>
          <a4j:htmlCommandLink id="_#{item.username}_editLink" action="editUser">
               <f:setPropertyActionListener value="#{item.id}" target="#{utentiBean.id}"/>
              <h:outputText value="#{item.username}"/>
          </a4j:htmlCommandLink>
      </rich:column>
      
      
      
      
      

       

      #{item.username} is not null because i can see it rendered in the table <h:outputText value="#{item.username}"/> but the link id is not correct, it is in this form:

      id="j_id70:superList_tbl:1:__editLink"

       

      Thanks for any help

        • 1. a4j:htmlCommandLink dynamic id not working
          Nick Belaevski Master

          Hi,

           

          How does 'item' is defined on the page?

          • 2. a4j:htmlCommandLink dynamic id not working
            Stefano C Newbie

            Hi Nick,

             

            'item' is the var attribute of a rich:dataTable, i've my own component that wraps a rich:dataTable:

             

            <link:dataTable id="superList"

                                                                        value="#{utentiDM}"

                                                                        headerText="Lista Utenti"

                                                                        showSelectAll="true"

                                                                        selectionMapTarget="#{utentiBean.selectedIds[item]}"

                                                                        mBean="#{utentiBean}">

             

                                                                        <rich:column>

                                                                                  <f:facet name="header">

                                                                                            <h:outputText value="Username" />

                                                                                  </f:facet>

                                                                                  <a4j:htmlCommandLink action="editUser">

                                                                                            <f:setPropertyActionListener value="#{item.id}" target="#{utentiBean.id}"/>

                                                                                            <h:outputText value="#{item.username}"/>

                                                                                  </a4j:htmlCommandLink>

                                                                        </rich:column>

                                                                        <rich:column>

                                                                                  <f:facet name="header">

                                                                                            <h:outputText value="Soggetti Associati" />

                                                                                  </f:facet>

                                                                                  <a4j:htmlCommandLink action="editUser">

                                                <f:setPropertyActionListener value="#{item.id}" target="#{utentiBean.id}"/>

                                                <h:outputText id="sizeSoggetti" value="Visualizza (#{item.sizeSoggetti})" rendered="#{item.sizeSoggetti>0}" />

                                                <rich:toolTip value="#{item.nomiSoggettiAssociati}" for="sizeSoggetti" rendered="#{item.sizeSoggetti>0}"/>

                                        </a4j:htmlCommandLink>

             

                                                                        </rich:column>

                                                                        <ui:define name="buttons">

                                                                                  <h:commandButton styleClass="icon-add" value="Aggiungi Nuovo" action="editUser"/>

                                                                        </ui:define>

                                                              </link:dataTable>

             

            where link:dataTable inside is:

             

            <rich:dataTable 

                                                    value="#{value}"

                                                    var="item"

                                                    rows="#{rowsToDisplay}"

                                                    id="#{id}_tbl"

                                                    onRowMouseOver="activeRow(this)"

                                                    rowClasses="even,odd"

                                                    width="#{width}">

            ....

            ....

            ...

            • 3. a4j:htmlCommandLink dynamic id not working
              Nick Belaevski Master

              It doesn't work that way - component tree is built and id is assigned *before* collection is iterated over.

              • 4. a4j:htmlCommandLink dynamic id not working
                Stefano C Newbie

                so it's not possible to use a value from the collection to build the id? If you would like to create an id depending on some value of your collection, there is a way to do that?

                • 5. a4j:htmlCommandLink dynamic id not working
                  Nick Belaevski Master

                  Generally no, check this article that describes the related problem: http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets