3 Replies Latest reply on Jun 3, 2010 12:55 PM by Johannes Freudendahl

    ExtendedDataTable: weird selection behavior

    Johannes Freudendahl Newbie

      I'm working on a JSF view using rich:extendedDataTable (RichFaces 3.3.3, MyFaces, Spring 3) and am seeing some weird behavior when it comes to selecting rows in the table. I can select single lines just fine, but selecting multiple line sseems off: I select line 1 and then click on line 2, pressing Shift -- visually, only line 2 is marked as selected though in the backing bean both rows are set as selected. If I try the same with three rows, it gets worse: I click on line 1, then press Shift and click on line 3 -- line 1 is not selected anymore, but lines 2 to 4 are. In the backing bean, all four are selected. Any ideas what could be causing this?!

       

      Simplified table code (can I mark this as code somehow?! Not seeing any buttons for it...):

       

      <rich:extendedDataTable id="masterDataTable"
                                           value="#{fapsMasterDataBean.dataModel}"
                                           var="nextMasterData"
                                           sortMode="single"
                                           rows="0"
                                           activeClass="rich-table-selected"
                                           selectedClass="rich-table-selected"
                                           rowClasses="odd, even"
                                           selection="#{fapsMasterDataBean.masterDataSelection}"
                                           selectionMode="multi">
        <rich:column id="mdValue" label="Name" width="400px">
          <f:facet name="header"><h:outputText value="Name"/></f:facet>
          <h:outputText value="#{nextMasterData.value}" />
        </rich:column>
      </rich:extendedDataTable>

        • 1. Re: ExtendedDataTable: weird selection behavior
          Johannes Freudendahl Newbie

          To add to the above, I had time to look at the CSS classes with Firebug. The table is defined with selectedClass="rich-table-selected", so I would expect all selected rows to have this class.

           

          Problem 1

          Example: select line 1

          CSS classes line 1: extdt-firstrow rich-extdt-firstrow odd extdt-row-selected rich-sdt-row-selected rich-table-selected extdt-row-active rich-sdt-row-active

           

          Example: select line 1, then press Shift and select line 2

          CSS classes line 1: extdt-firstrow rich-extdt-firstrow odd extdt-row-selected rich-sdt-row-selected

          CSS classes line 2: extdt-firstrow rich-extdt-firstrow even extdt-row-selected rich-sdt-row-selected rich-table-selected extdt-row-active rich-sdt-row-active

           

          This seems to be wrong, but the obvious workaround would be not to use the selectedClass attribute and instead to define all possible default classes in the stylesheet (we use both scrollable and extended data table and thought this would be easier).

           

          Problem 2

          Example: select line 1, then press Shift and select line 3

          CSS classes line 1: extdt-firstrow rich-extdt-firstrow odd extdt-row-selected rich-sdt-row-selected

          CSS classes line 2: extdt-firstrow rich-extdt-firstrow even extdt-row-selected rich-sdt-row-selected rich-table-selected

          CSS classes line 3: extdt-firstrow rich-extdt-firstrow odd extdt-row-selected rich-sdt-row-selected rich-table-selected extdt-row-active rich-sdt-row-active

          CSS classes line 4: extdt-firstrow rich-extdt-firstrow even extdt-row-selected rich-sdt-row-selected rich-table-selected

           

          The backing bean confirms that in the last example actually four rows instead of three have been selected. Testing a bit more, it seems that a line that I haven't clicked on is only selected when I select multiple lines the last of which is the second-to-last line. In that case it will erroeously also select the last line. Selecting two or three lines works (apart from the first selected line not getting the right class) if I stay away from the end of the table.

           

          This actually happens in your demo page, too: Select "Washington", press Shift and simultaneoulsy select "Wisconsin" -- four rows instead of three are selected, "Washington" to "Wyoming". So... Should I open a bug for this?!

          • 2. Re: ExtendedDataTable: weird selection behavior
            Ilya Shaikovsky Master
            This actually happens in your demo page, too: Select "Washington", press Shift and simultaneoulsy select "Wisconsin" -- four rows instead of three are selected, "Washington" to "Wyoming". So... Should I open a bug for this?!

            Issue for that already in jira. https://jira.jboss.org/browse/RF-8680

             

            To add to the above, I had time to look at the CSS classes with Firebug. The table is defined with selectedClass="rich-table-selected", so I would expect all selected rows to have this class.

            you could rise issue for that but in your case I think it would be easier not to wait (espesially considering the fact that 3.3.x is closed and not going to be released anymore)  but use rich-* classes provided and if you have to differentiate them between tables - use selectors with id's or table styleClasses.

            • 3. Re: ExtendedDataTable: weird selection behavior
              Johannes Freudendahl Newbie

              Thanks for the information! I forgot to look for this on JIRA. :-/

               

              As for the other problem: Yes, it's not terribly important and I just put all relevant classes in the CSS file since they're supposed to look the same in all tables anyway. I nonetheless created a JIRA entry for this so that others might not be confused by this in the future: https://jira.jboss.org/browse/RF-8726