sortBy problem on nested dataTable
jbn Oct 20, 2009 2:01 PMI am having an issue using the sortBy attribute on the rich:column in a rich:dataTable that is nested in another table (h:dataTable or rich:dataTable). In the AJAX response, it looks like the outer table iteration count is lost from the inner table id as there is an error on the replace as seen in the a4j:log. Here is a simple demo:
WAS 6.1
Facelets
MyFaces 1.2.7
RichFaces 3.3.1
The page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <a4j:log id="log" popup="true" hotkey="l"/> <body> <h:dataTable id="ordersTable" value="#{test.orders}" var="order" > <h:column> <h:form id="orderForm" > <rich:dataTable id="orderTable" value="#{order.contents}" var="item" > <rich:column sortBy="#{item.name}" > <f:facet name="header" > <h:outputText value="Name" /> </f:facet> <h:outputText value="#{item.name}" /> </rich:column> <rich:column sortBy="#{item.quantity}" > <f:facet name="header" > <h:outputText value="Quantity" /> </f:facet> <h:outputText value="#{item.quantity}" /> </rich:column> </rich:dataTable> </h:form> </h:column> </h:dataTable> </body> </html>
The backing bean:
import java.util.ArrayList; import java.util.List; public class Test { private List<Order> orders; public Test() { List<Item> items = new ArrayList<Item>(); items.add(new Item("Orange", 12)); items.add(new Item("Banana", 6)); items.add(new Item("Apple", 9)); items.add(new Item("Pear", 1)); orders = new ArrayList<Order>(); orders.add(new Order("037219", items)); } public List<Order> getOrders() { return orders; } public void setOrders(List<Order> orders) { this.orders = orders; } public class Order { private String number; private List<Item> contents; public Order() {} public Order(String number, List<Item> contents) { this.number = number; this.contents = contents; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public List<Item> getContents() { return contents; } public void setContents(List<Item> contents) { this.contents = contents; } } public class Item { private String name; private int quantity; public Item() {} public Item(String name, int quantity) { this.name = name; this.quantity = quantity; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } } }
Can someone please tell me what I'm doing wrong...or at least point me in the right direction?
Thank you!