5 Replies Latest reply on Apr 16, 2014 12:03 PM by ringodw

    Problem with selection on extendedDataTable built with c:forEach

    quajo

      Hi, I have in a page a extendedDataTable built with c:forEach because the data that can contain it depends on some input fields. The problem is the data is shown perfectly but the selection on the table rows is not working. The weird thing is when I refresh the page with F5 in firefox, the selection starts to work, but in the first load it doesn´t work.

       

      The code of the table is the following:

       

      <h:form>

                       <rich:extendedDataTable value="#{exttable.actas}"

                          selection="#{exttable.selection}" height="80px" id="actasList"

                          rows="0" var="act" styleClass="scroll">

                          <a4j:ajax execute="@form" event="selectionchange"

                              listener="#{exttable.selectionListener}" render=":res" />

                          <c:forEach items="#{exttable.columns}" var="colum">

                              <rich:column>

                                  <f:facet name="header">

                                      <h:outputText value="#{colum.cabecera}" />

                                  </f:facet>

                                  <h:outputText value="#{act[colum.valor]}" />

                              </rich:column>

                          </c:forEach>

                      </rich:extendedDataTable>

      </h:form>

       

      where colum has the values of the header and the value fields of the different objects the extendeddatatable can contain:

       

      public class ColumnaDinamica {

         

          private String cabecera;

          private String valor;

         

          public String getCabecera() {

              return cabecera;

          }

          public void setCabecera(String cabecera) {

              this.cabecera = cabecera;

          }

          public String getValor() {

              return valor;

          }

          public void setValor(String valor) {

              this.valor = valor;

          }

       

      Any Idea? Thanks!!!

        • 1. Re: Problem with selection on extendedDataTable built with c:forEach
          paul.dijou

          I'm really sorry to say that, but you should not use "<c:forEach>" inside an extendedDataTable. JSTL tags like "<c:forEach>" are not part of the JSF lifecycle and are evaluated only once when the page is loaded, any JSF Ajax will no impact them for what I know.

           

          Have you consider using "<rich:columns>" tag instead of "<c:forEach>" ? Or "<a4j:repeat>" ?

          • 2. Re: Problem with selection on extendedDataTable built with c:forEach
            quajo

            Hi Paul, Thanks for your answer. I´m trying doing it now with<a4j:repeat> but nothing is shown:

             

                           <rich:extendedDataTable value="#{exttable.actas}" var="act"

                                id="actasList">

                                <a4j:repeat value="#{exttable.columns}" var="vcol">

                                    <rich:column>

                                        <f:facet name="header">

                                            <h:outputText value="#{act[vcol.cabecera]}" />

                                        </f:facet>

                                        <h:outputText value="#{act[vcol.valor]}" />

                                    </rich:column>

                                </a4j:repeat>

                            </rich:extendedDataTable>

             

            I don´t know why it´s not working. I´ve read in this old post: https://community.jboss.org/message/521751, that this way of create dynamic columns was in preparation, I don´t know if it´s ready. Any way of showing the change of columns if the structure of objects in the list below changes and different columns has to be shown?

            • 3. Re: Problem with selection on extendedDataTable built with c:forEach
              paul.dijou

              If you are using RichFaces 3.x, go with <rich:columns>.

               

              If you are using RichFaces 4.x.... ... ... <c:forEach> is the only way I know, right now, to have dynamic columns in this version (I was hoping that <a4j:repeat> would work, but no... I guess <ui:repeat> will not work either). The problem is that <c:forEach> will not like JSF ajax.

               

              I will bring the problem to the next RichFaces meeting and will provide you feedback. Don't hesitate to spam me if no news before the end of next week.

               

              Regards,

              • 4. Re: Problem with selection on extendedDataTable built with c:forEach
                quajo

                Thanks Paul, I´m using richfaces 4.2, so I´ll be waiting for some news.

                 

                Thanks again!

                • 5. Re: Problem with selection on extendedDataTable built with c:forEach
                  ringodw

                  Hi all!  Does someone have a workaround for this?  We are using 4.3.5, and have an EDT with dynamic columns using <c:forEach>.  The row selection seems to work with a F5 refresh like above.  Getting desperate, but even a JS call to refresh using window.location.reload() on our table search button is not working consistently...