ExtendedDataTable selection null in ui:include page
mariulin Nov 14, 2014 8:19 AMGreetings Everyone.
Im facing a problem with extendeddatatable and I will try to explain, I'm sorry if my english is not so good, maybe Im doing something wrong because Im pretty new in Richfaces and I spent some hours searching how to fix my problem but didnt found a solution.
Im using Richfaces 4.3.7 (I tried with 4.5.0 but still have the problem) and Mojara 2.2.0 with Hibernate (MySql Db) and Tomcat 8.0
I have a Homepage (.xhtml) with on the left commands and on right a ui:include inside a a4j outputpanel with src pointing to a backing bean proprierties, follow the portion of code of the ui:include.
<a4j:outputPanel ajaxRendered="true" id="targetArea" layout="block"> <ui:include src="#{homeBean.centralPage}" /> </a4j:outputPanel>
This is the page included:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <html> <rich:extendedDataTable value="#{ordiniBean.documenti}" var="docum" id="table_docs" rows="60" selection="#{ordiniBean.selection}" selectionMode="single" style="height:#{sessionParameters.tableHeight1}px;width:692px"> <a4j:ajax event="selectionchange" listener="#{ordiniBean.selectionListener}" /> <rich:column width="90px"> <f:facet name="header"> <h:outputText value="Data" /> </f:facet> <h:outputText value="#{docum.docData}"> <f:convertDateTime type="date" pattern="dd/MM/yyyy" /> </h:outputText> </rich:column> </rich:extendedDataTable> </html> </ui:composition>
The extendeddatatable has a selection and a a4j:ajax event="selectionchange" that point at a listener in the backingbean:
private Collection<Object> selection; public Collection<Object> getSelection() { return selection; } public void setSelection(Collection<Object> selection) { this.selection = selection; } public void selectionListener(AjaxBehaviorEvent event) { AbstractExtendedDataTable dataTable = (AbstractExtendedDataTable)event.getComponent(); Object originalKey = dataTable.getRowKey(); selectionItems.clear(); for (Object selectionKey : selection) { dataTable.setRowKey(selectionKey); if (dataTable.isRowAvailable()) { selectionItems.add((DocPartite) dataTable.getRowData()); } } dataTable.setRowKey(originalKey); }
The problem I have is that when the event its fired my variable "selection" its always null.
I think the problem its because the page its loaded in a ui:include because if I launch the page like a "stand-alone" page I have no problem with that and the selection has inside the righe row.
The page has some other little problem when loaded using the ui:include.
Thank you very much.
Best Regards, Mario.