8 Replies Latest reply on Mar 3, 2009 3:49 PM by alexsmirnov

    a4j:outputPanel with rendered=false doesn't disappear

      I have found that the rendered attribute does not work in conjunction with the a4j:outputPanel tag (attribute layout="none").
      To start with the expression for a simpleTogglePanel rendered is false. The panel is hidden correctly.
      The simpleTogglePanel is displayed when the rendered expression evaluates to true as expected.
      However, when the rendered expression subsequently evaluates to false again the simpleTogglePanel doesn't disappear.

      Below I've included some screenshots, the facelet, managed bean, faces-config.xml and web.xml files.

      Thanks for your help.

      Screenshots:
      1 - When rendered evaluates to false:
      http://g.imagehost.org/view/0465/1_rendered_false.jpg

      2 - When rendered evaluates to true:
      http://f.imagehost.org/view/0435/2_rendered_true.jpg

      3 - When rendered evaluates to false again:
      http://f.imagehost.org/view/0819/3_rendered_false_after_true.jpg

      Facelet (test.xhtml):

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j">
       <head>
       </head>
       <body>
       <h:form>
       <h:panelGrid columns="1">
       <h:outputText id="debug" value="value: #{testBean.value}"/>
       <a4j:outputPanel layout="none">
       <rich:simpleTogglePanel id="testPanel" switchType="client" label="simpleTogglePanel" rendered="#{!empty testBean.value}">
       <h:outputText value="test panel - should be hidden when value is empty"/>
       </rich:simpleTogglePanel>
       </a4j:outputPanel>
       <a4j:commandButton value="populate" actionListener="#{testBean.populate}" reRender="debug,testPanel"/>
       <a4j:commandButton value="clear" actionListener="#{testBean.clear}" reRender="debug,testPanel"/>
       </h:panelGrid>
       </h:form>
       </body>
      </html>
      


      Managed bean:
      import javax.faces.event.ActionEvent;
      
      /**
       * Backing bean for the Test page.
       *
       * @author Benjamin Outram.
       */
      public class TestBean
      {
       private String value;
      
       public TestBean()
       {
       }
      
       public void populate(ActionEvent event)
       {
       value = "hello world";
       }
      
       public void clear(ActionEvent event)
       {
       value = null;
       }
      
       public String getValue()
       {
       return value;
       }
      
       public void setValue(String value)
       {
       this.value = value;
       }
      }
      


      Faces-Config:
      <?xml version='1.0' encoding='UTF-8'?>
      <faces-config version="1.2"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
       <application>
       <view-handler>
       com.sun.facelets.FaceletViewHandler
       </view-handler>
       </application>
       <managed-bean>
       <managed-bean-name>testBean</managed-bean-name>
       <managed-bean-class>TestBean</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       </managed-bean>
      </faces-config>
      


      Web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>false</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.VIEW_MAPPINGS</param-name>
       <param-value>*.xhtml</param-value>
       </context-param>
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <session-config>
       <session-timeout>
       30
       </session-timeout>
       </session-config>
       <welcome-file-list>
       <welcome-file>faces/test.xhtml</welcome-file>
       </welcome-file-list>
      </web-app>
      


      Environment:
      Java: jdk1.6.0_12
      JSF: Reference Impl 1.2_04-b10-p01
      IDE: Netbeans 6.0.5 (Build 200811100001)
      Application Server: Tomcat 6.0.18
      Richfaces: 3.2.1.GA

      Libraries:
      JSF 1.2
      JSTL 1.1
      Facelets 1.1.13
      Commons BeanUtils 1.7.0
      Commons Collections 3.2
      Commons Digester 1.8
      Commons Logging 1.1