2 Replies Latest reply on Dec 4, 2014 9:09 AM by jorei

    Possible Bug: Action not executed from dataTable (multible tables with varying content)

    jorei

      I encountered some strange behaviour with the rich:dataTable. I have a setup in which I have several documents per category. I iterate over the categories and display the related documents in a dataTable, thus one table per category. Each document contains a link, however, clicking the link had no result, i.e. the action-method was never called. After ruling out lots of possible reasons (see this list) and reducing the code to a minimal testcase I now believe this might be a bug. See the code below. When playing around with you can see that it affects only links in the second and third table, and then only the ones that these tables have in addition to the first one. It seems that when processing the command-components the first table sets the standard (e.g. 2 elements) and all others are treated the same way, i.e. having only two links, too.

       

      The normal JSF h:dataTable (left list of links) does not show this behaviour. However, in the live code I need a few of the rich:dataTable-features (e.g. iteration variable), hence I can't switch. I hope that some of the RichFaces developers can have a look at this, because I can't figure out any more details about the internal JSF processing of the links. If this is indeed a bug let me know and I will create a Jira issue. Any workarounds are greatly appreciated.

       

      PS: Sorry to say that, but this forum is a usability nightmare. I was willing to search for similar issues, but got quite frustrated with the search and the results table. If this is a duplicate, please blame the search

       

      ManagedBean

      @ManagedBean

      @ViewScoped

      public class TestController implements Serializable {

           private Long[] idArray = {1L, 2L, 3L}; // + Getter

           private Map<Long, List<String>> map;  // + Getter

           private int number; // + Getter

       

          @PostConstruct

          private void init() {

              map = new HashMap<Long, List<String>>();

       

              List<String> list1 = new ArrayList<String>();

              list1.add("One");

              list1.add("Two");

              map.put(1L, list1);

       

              List<String> list2 = new ArrayList<String>();

              list2.add("One");

              list2.add("Two");

              list2.add("Three");

              map.put(2L, list2);

       

              List<String> list3 = new ArrayList<String>();

              list3.add("One");

              list3.add("Two");

              list3.add("Three");

              list3.add("Four");

              map.put(3L, list3);

          }

       

          public void doSomething() {

              System.out.println("Did something");

              number++;

          }

      }

       

      View

              <h:form>

                  <h1>#{testController.number}</h1>

       

                  <ui:repeat id="repeat" value="#{testController.idArray}" var="value" varStatus="i">

                      <h2 style="clear: both;">#{value}</h2>

       

                      <h:dataTable id="table2" value="#{testController.map[value]}" var="entry" style="float:left; width: 40%;">

                          <h:column>

                              <h:commandLink action="#{testController.doSomething}" value="#{entry}"/>

                          </h:column>

                      </h:dataTable>

       

                      <rich:dataTable id="table3" value="#{testController.map[value]}" var="entry" style="float:left; width: 40%;">

                          <rich:column>

                              <h:commandLink action="#{testController.doSomething}" value="#{entry}"/>

                          </rich:column>

                      </rich:dataTable>

                  </ui:repeat>

              </h:form>