Problem with a4j:support in dataTable header facet
lanceb185 Jul 9, 2008 12:50 PMHi
I have a strange problem where a h:selectBooleanCheckbox with a4j:support attached is not updating the backing bean when inserted in a header facet. The same call made from check boxes within the table's cells or elsewhere on the form works.
Refer to the check box "header_check" in the listing below - that is not working, although the check box "line_check" within the table works and calls the backing bean method.
Help much appreciated
Lance
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="styles.css" rel="stylesheet" type="text/css"/>
<title>Basic Sandbox</title>
</head>
<body>
<f:view>
<h:form id="form1">
<a4j:outputPanel>
<rich:messages/>
</a4j:outputPanel>
<h:outputText value="Some basic components wired to backing bean"/>
<p>
<h:inputText id="text" value="#{bean.text}"/>
<h:dataTable id="table" bgcolor="cyan" value="#{bean.data}" var="line">
<h:column id="id">
<f:facet name="header">
<h:panelGroup>
<h:selectBooleanCheckbox id="header_check"
value="#{bean.headerCheck}">
<a4j:support event="onchange"
ajaxSingle="true" reRender="form2,test"/>
</h:selectBooleanCheckbox>
<h:outputText value="ID"/>
</h:panelGroup>
</f:facet>
<h:outputText value="#{line.id}"/>
<f:facet name="footer"/>
</h:column>
<h:column id="desc">
<f:facet name="header">
<h:outputText value="DESC"/>
</f:facet>
<h:outputText value="#{line.desc}"/>
<f:facet name="footer"/>
</h:column>
<h:column id="enabled">
<f:facet name="header">
<h:outputText value="ENABLED"/>
</f:facet>
<h:selectBooleanCheckbox value="#{line.enabled}" id="line_check">
<a4j:support ajaxSingle="true" event="onchange"/>
</h:selectBooleanCheckbox>
<f:facet name="footer"/>
</h:column>
</h:dataTable>
</h:form>
<h:form id="form2">
<h:commandButton value="Press Me"
id="button"
action="#{bean.buttonPressed}"/>
<h:selectBooleanCheckbox id="test"
value="#{bean.headerCheck}">
<a4j:support ajaxSingle="false"
event="onchange"
reRender="form2,test"/>
</h:selectBooleanCheckbox>
<h:outputText value="check me"/>
</h:form>
</f:view>
</body>
</html>
import java.util.ArrayList;
import java.util.List;
public final class Bean {
private final List<Line> data;
private String text;
private boolean headerCheck = false;
public Bean() {
data = new ArrayList<Line>();
data.add(new Line("one", "the first line", false));
data.add(new Line("two", "the second line", false));
data.add(new Line("three", "the third line", false));
}
public boolean isHeaderCheck() {
return headerCheck;
}
public void setHeaderCheck(boolean headerCheck) {
this.headerCheck = headerCheck;
System.out.println("Bean.setHeaderCheck value: " + headerCheck);
}
public List<Line> getData() {
return data;
}
public void setText(String text) {
System.out.println("Bean.setText, text: " + text);
this.text = text;
}
public String getText() {
return text;
}
public void buttonPressed() {
System.out.println("Bean.buttonPressed!!!!!");
}
public final class Line {
private final String id;
private final String desc;
private boolean enabled;
public Line(String id, String desc, boolean enabled) {
this.id = id;
this.desc = desc;
this.enabled = enabled;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
System.out.println("Bean.Line.setEnabled invoked: " + enabled);
}
public String getDesc() {
return desc;
}
public String getId() {
return id;
}
} // Line
}