2 Replies Latest reply on May 28, 2009 2:07 PM by Thomas W

    Capturing scrollableDataTable selection w/o full table decod

    Thomas W Newbie

      I have a scrollableDataTable for which I want to record the selection in a bean. The table should not re-render as part of selection change.

      <rich:scrollableDataTable id="someTable"
      <a:support event="onselectionchange"
      reRender="region1, region2"

      The problem with this setup: Whenever selection changes, the entire table is processed on the server side. What I need is the ability to just capture the selection and reRender other sections of the screen outside of the table region/form. No processing of the table component.

      Would it be possible (using the RF infrastructure) to define a separate form for the selection only and trigger its submit from the onselectionchange handler?

        • 1. Re: Capturing scrollableDataTable selection w/o full table d
          Konstantin Mishin Novice

          It isn't possible to define a separate form for the selection now.

          • 2. Re: Capturing scrollableDataTable selection w/o full table d
            Thomas W Newbie

            This is really something that should be addressed. Selection on the table typically does not change what is shown in the table and therefore any full processing of the table on the server is unwanted overhead. This is also not too difficult to accomplish. I will post my solution below in case someone else needs it and log a JIRA enhancement request.

            Define separate form for selection:

             <a:jsFunction name="setScrollableDataTableSelection"
             <a:actionparam name="param1" assignTo="#{myAction.scrollableDataTableSelection}" />

            Link it from the table:

            (to replace existing onselectionchange a:support tag.)

            Finally, the Java code needs to parse the selection string and in this case converts it into SimpleSelection:

             public void setScrollableDataTableSelection(String selection) {
             log.info("scrollableDataTableSelection {0}", selection);
             if (selection == null) {
             String[] tokens = selection.split(";");
             SimpleSelection newSelection = new SimpleSelection();
             for (String token : tokens) {
             Matcher m = Pattern.compile("(\\d+),(\\d+)").matcher(token);
             if (m.find()) {
             int startIndex = Integer.parseInt(m.group(1));
             int endIndex = Integer.parseInt(m.group(2));
             for (int i=startIndex; i<=endIndex; i++) {
             if (i <= this.rowIds.size()) {
             this.selection = newSelection;