This content has been marked as final.
Show 2 replies
-
1. Re: Capturing scrollableDataTable selection w/o full table d
konstantin.mishin May 20, 2009 6:47 AM (in response to tw)It isn't possible to define a separate form for the selection now.
-
2. Re: Capturing scrollableDataTable selection w/o full table d
tw May 28, 2009 2:07 PM (in response to tw)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:<h:form> <a:jsFunction name="setScrollableDataTableSelection" reRender="selectionDetailArea" limitToList="true" ajaxSingle="false" <a:actionparam name="param1" assignTo="#{myAction.scrollableDataTableSelection}" /> </a:jsFunction> </h:form>
Link it from the table:onselectionchange="javascript:setScrollableDataTableSelection($('#{rich:clientId('myTable')}:s').value);"
(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) { return; } 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()) { newSelection.addKey(this.rowIds.get(i).intValue()); } } } } this.selection = newSelection; }