dataTable bug ?
humanoid Mar 16, 2009 8:16 AMon select any value in select menu value send to server, but dataTable header not update:
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head><title>test</title></head> <body> <f:view> <h:form> <h:selectOneListbox size="1" style="width: 580px;" value="#{testTable2.sel}" onchange="this.form.submit()" valueChangeListener="#{testTable2.OnChangeDataSection}" > <f:selectItem itemLabel="1" itemValue="1"/> <f:selectItem itemLabel="2" itemValue="2"/> </h:selectOneListbox> <rich:dataTable binding="#{testTable2.htmlDataTable}" /> </h:form> </f:view> </body> </html>
package test; import org.richfaces.component.html.HtmlDataTable; import org.richfaces.component.html.HtmlColumn; import org.richfaces.component.html.HtmlColumnGroup; import javax.faces.event.ValueChangeEvent; import javax.faces.component.html.HtmlOutputText; public class TestTable2 { HtmlDataTable htmlDataTable; Long sel; public TestTable2() { sel = 1l; FillTable(); } public Long getSel() { return sel; } public void setSel(Long sel) { this.sel = sel; } public HtmlDataTable getHtmlDataTable() { return htmlDataTable; } public void setHtmlDataTable(HtmlDataTable htmlDataTable) { this.htmlDataTable = htmlDataTable; } public void OnChangeDataSection(ValueChangeEvent ev) { sel = Long.valueOf(ev.getNewValue().toString()); FillTable(); } private void FillTable() { htmlDataTable = new HtmlDataTable(); HtmlColumnGroup hcl = new HtmlColumnGroup(); hcl.getChildren().add(getCol("1")); if (sel > 1) { hcl.getChildren().add(getCol("2")); } htmlDataTable.getFacets().put("header", hcl); } private HtmlColumn getCol(String text) { HtmlColumn col = new HtmlColumn(); HtmlOutputText t = new HtmlOutputText(); t.setValue(text); col.getChildren().add(t); return col; } }
binding update only first page load