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

      Lance

       <f:view>
       <h:form id="sandbox_form">
       <h:dataTable id="bean_table"
       value="#{bean.lines}"
       var="line"
       styleClass="table-settings"
       columnClasses="column-settings">
       <h:column id="id_col">
       <f:facet name="header">
       <h:panelGrid>
       <h:panelGroup>
       <h:selectBooleanCheckbox value="#{bean.headerCheckSelected}">
       <a4j:support action="onchange" ajaxSingle="true"
       reRender="sandbox_form,bean_table,check_one"/>
       </h:selectBooleanCheckbox>
       <h:outputText value="ID_FIELD"/>
       </h:panelGroup>
       </h:panelGrid>
       </f:facet>
       <h:outputText id="id_col_txt"
       value="#{line.id}"
       rendered='#{line.id != ""}'/>
       </h:column>
      


        • 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"...


          J.R.

          • 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"
            "http://www.w3.org/TR/html4/loose.dtd">
            
            <%--
             A very basic test JSF form.
            --%>
            
            <html>
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
             <title>Basic Sandbox</title>
             </head>
             <body>
             <f:view>
             <h:form id="form1">
             <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 value="#{bean.headerCheck}">
             <a4j:support event="onchange" ajaxSingle="true" reRender="form1,table"/>
             </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}">
             <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>
            


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


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

            Help appreciated
            Lance

            • 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
              Lance