3 Replies Latest reply on Jul 8, 2008 11:39 AM by Lance Buchan

    a4j:support not working in table header facet

    Lance Buchan Newbie

      A <h:selectBooleanCheckbox> in a table header facet is not working correctly with a4j:support. See the snippet below. The check box in the header facet is supposed to call the bean.setHeaderCheckSelected method but this is not happening. (When I insert the same check box in one of the table cells, this works.)

      Help much appreciated


       <h:form id="sandbox_form">
       <h:dataTable id="bean_table"
       <h:column id="id_col">
       <f:facet name="header">
       <h:selectBooleanCheckbox value="#{bean.headerCheckSelected}">
       <a4j:support action="onchange" ajaxSingle="true"
       <h:outputText value="ID_FIELD"/>
       <h:outputText id="id_col_txt"
       rendered='#{line.id != ""}'/>

        • 1. Re: a4j:support not working in table header facet
          J.R. Ector Newbie

          Not sure which version of Richfaces you're using but, it should be
          <a4j:support event="onchange"...


          • 2. Re: a4j:support not working in table header facet
            Lance Buchan Newbie

            Richfaces 3.2.0SR1.

            My mistake on the code listing. I changed that to event="onchange" but I'm still not getting it to work (backing bean setter is simply not called), in fact neither in the header facet nor separately. The page renders no problem but selecting the check boxes has no effect.

            Here's a full listing:

            <%@page contentType="text/html"%>
            <%@page pageEncoding="ISO-8859-1"%>
            <%@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"%>
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
             A very basic test JSF form.
             <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
             <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 value="#{bean.headerCheck}">
             <a4j:support event="onchange" ajaxSingle="true" reRender="form1,table"/>
             <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}">
             <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"/>

            And the backing bean:
             * Bean.java 1.0 31/05/2008
            import java.util.ArrayList;
            import java.util.List;
             * @author Lance Buchan
            public final class Bean {
             private final List<Line> data;
             private String text;
             private boolean headerCheck = false;
             /** Creates a new instance of Bean */
             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

            There must be something strange in the project config because I've had this working before.

            Help appreciated

            • 3. Re: a4j:support not working in table header facet
              Lance Buchan Newbie

              Ok, the above is not relevant - I had the Richfaces settings missing in web.xml.

              However, the initial problem still exists - the a4j:support which supports the selectBooleanCheckbox in the ID header facet is not making the Ajax call.

              Help much appreciated on this