4 Replies Latest reply on Jul 14, 2008 8:33 AM by Ilya Shaikovsky

    Problem with a4j:support in dataTable header facet

    Lance Buchan Newbie


      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

      <%@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"%>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <link href="styles.css" rel="stylesheet" type="text/css"/>
       <title>Basic Sandbox</title>
       <h:form id="form1">
       <h:outputText value="Some basic components wired to backing bean"/>
       <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:selectBooleanCheckbox id="header_check"
       <a4j:support event="onchange"
       ajaxSingle="true" reRender="form2,test"/>
       <h:outputText value="ID"/>
       <h:outputText value="#{line.id}"/>
       <f:facet name="footer"/>
       <h:column id="desc">
       <f:facet name="header">
       <h:outputText value="DESC"/>
       <h:outputText value="#{line.desc}"/>
       <f:facet name="footer"/>
       <h:column id="enabled">
       <f:facet name="header">
       <h:outputText value="ENABLED"/>
       <h:selectBooleanCheckbox value="#{line.enabled}" id="line_check">
       <a4j:support ajaxSingle="true" event="onchange"/>
       <f:facet name="footer"/>
       <h:form id="form2">
       <h:commandButton value="Press Me"
       <h:selectBooleanCheckbox id="test"
       <a4j:support ajaxSingle="false"
       <h:outputText value="check me"/>

      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() {
       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