SimpleSelection doesn't work in Seam
dxxvi Feb 28, 2009 6:18 AMI have 2 Seam components:
@Stateful @Name("customerList") public class CustomerListImpl implements CustomerList { @Logger protected Log log; @PersistenceContext(type= PersistenceContextType.EXTENDED) protected EntityManager entityManager; @DataModel("customers") protected List<Customer> customers; @In(value="customerComponents", required=false) protected CustomerComponents customerComponents; public void viewSelectedRows() { Iterator<Object> iterator = customerComponents.getSelection().getKeys(); while (iterator.hasNext()) { Object key = iterator.next(); customerComponents.getDataTable().setRowKey(key); Object customer = customerComponents.getDataTable().getRowData(); customer = null; } } @SuppressWarnings("unchecked") public void findCustomers() { log.debug(null); customers = entityManager.createQuery("select c from Customer c").getResultList(); } public void goToPanelBarItem() { log.debug(customerComponents.getPanelBar().getSelectedPanel()); } @Destroy @Remove public void destroy() { } } @Local public interface CustomerList { void viewSelectedRows(); void findCustomers(); void goToPanelBarItem(); void destroy(); } @Name("customerComponents") @Scope(ScopeType.EVENT) public class CustomerComponents { private HtmlScrollableDataTable dataTable; private SimpleSelection selection; private HtmlPanelBar panelBar; // ... getters & setters }
My xhtml
<a4j:form> <rich:scrollableDataTable value="#{customers}" var="customer" width="70px" height="200px" binding="#{customerComponents.dataTable}" selection="#{customerComponents.selection}"> <rich:column width="48px"> <f:facet name="header">ID</f:facet> <h:outputText value="#{customer.id}" /> </rich:column> </rich:scrollableDataTable> <a4j:commandLink value="View Selected Rows" action="#{customerList.viewSelectedRows}" reRender="selectedRowBox" /> <rich:panelBar binding="#{customerComponents.panelBar}" width="500"> <rich:panelBarItem name="barItem1" label="Leverage the whole set of JSF benefits ..."> <a4j:support event="onenter" action="#{customerList.goToPanelBarItem}"/> Ajax4jsf is fully integrated ... </rich:panelBarItem> <rich:panelBarItem name="barItem2" label="Add AJAX capability..."> <a4j:support event="onenter" action="#{customerList.goToPanelBarItem}"/> The framework is implemented ... </rich:panelBarItem> </rich:panelBar> </a4j:form> <h:panelGroup id="selectedRowBox"></h:panelGroup>
When I select some rows and click View Select Rows, the iterator is always empty.
When I enter a panel bar item, the goToPanelBarItem method prints the panel bar item name (that means the JSF component bindings work).
Does anybody know why the selection doesn't work?
Thank you.