maybe a bug in scrollableDataTable
lee64 Oct 30, 2008 11:03 AMFirst,in the scrollableDataTable online demo,click the table header,the row selected performance will not work,so click "Show Current Selection" buttom will not show the current selection.
But now,i have another problem.
I use scrollableDataTable,when selection changes the data of the first selection will be show in the page.
the strange thing is that i must scroll the scroll bar,then take selection,it will work fine.If not,the needed part will not be rerended,and java.lang.ArrayIndexOutOfBoundsException will be threw.
page code:
<h:form>
<h:panelGrid>
<h:outputText value="Files" />
<rich:scrollableDataTable
height="200px" width="800px" id="fileTable" rows="40"
value="#{fileUpload.fileList}" var="files"
binding="#{fileUpload.table}" selection="#{fileUpload.selection}">
......
<rich:column width="600">
<f:facet name="header"><h:outputText value="summary"/></f:facet>
<h:outputText value="#{files.summary}" />
</rich:column>
<a4j:support event="onselectionchange" reRender="newSum"/>
</rich:scrollableDataTable>
</h:panelGrid>
<h:panelGrid id="newSum">
<h:outputText value="#{fileUpload.firstFile.name}"/>
<h:inputTextarea cols="60" rows="5" value="#{fileUpload.firstFile.summary}"/>
<a4j:commandButton value="changeSummary" action="#{fileUpload.changeSummary}" />
<a4j:outputPanel ajaxRendered="true">
<rich:messages style="color: #FF0000; size: 12px"/>
</a4j:outputPanel>
</h:panelGrid>
</h:form>
back bean:
private SimpleSelection selection=new SimpleSelection();
private UIScrollableDataTable table;
private ArrayList<File> selectedFiles=new ArrayList<File>();
private File firstFile=new File();
......
public File getFirstFile() {
this.takeSelection();
if(selectedFiles.isEmpty()){
firstFile.setName("");
firstFile.setSummary("");
return firstFile;
}
firstFile=selectedFiles.get(0);
return firstFile;
}
public String takeSelection() {
getSelectedFiles().clear();
if (getSelection().isSelectAll()){
getSelectedFiles().addAll(fileList);
}
else{
Iterator<Object> iterator = getSelection().getKeys();
while (iterator.hasNext()){
Object key = iterator.next();
table.setRowKey(key);
if (table.isRowAvailable()) {
getSelectedFiles().add((File)table.getRowData());
}
}
}
return null;
}