2 Replies Latest reply on Apr 17, 2008 5:28 AM by Benjamin Outram

    rich:panelBar 3.2.0.GA does not work in JSP when bound to ma

    Benjamin Outram Newbie

      I have found that rich:panelBar does not work in a JSP if it is bound to a managed bean. However it works fine in a Facelet.

      Below I have included the managed bean and both the JSP and Facelet files.

      Environment:
      Java: jdk1.6.0_04
      JSF: Reference Impl 1.2_04-b10-p01
      IDE: Netbeans 6.0.1 (Build 200801291616)
      Application Server: Tomcat 6.0.14
      Richfaces: 3.2.0.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

      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>homeBean</managed-bean-name>
       <managed-bean-class>HomeBean</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/home.jsp</welcome-file>
       </welcome-file-list>
      </web-app>
      


      Managed bean:
      import javax.faces.component.html.HtmlOutputText;
      
      import org.richfaces.component.html.HtmlPanelBar;
      import org.richfaces.component.html.HtmlPanelBarItem;
      
      /**
       * Backing bean for the Home page.
       *
       * @author Benjamin Outram.
       */
      public class HomeBean
      {
       private HtmlPanelBar newsItems;
      
       public HomeBean()
       {
       newsItems = new HtmlPanelBar();
       newsItems.getChildren().add(buildNewsPanelItem());
       }
      
       private HtmlPanelBarItem buildNewsPanelItem()
       {
       HtmlPanelBarItem result = new HtmlPanelBarItem();
       result.setLabel("label text");
      
       HtmlOutputText content = new HtmlOutputText();
       content.setEscape(false);
       content.setValue("body text");
      
       result.getChildren().add(content);
      
       return result;
       }
      
       public HtmlPanelBar getNewsItems()
       {
       return newsItems;
       }
      
       public void setNewsItems(HtmlPanelBar newsItems)
       {
       this.newsItems = newsItems;
       }
      }
      


      JSP (home.jsp):
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <%@page contentType="text/html" pageEncoding="UTF-8"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <f:view>
       <html>
       <head>
       </head>
       <body>
       <h2>home.jsp</h2>
       <rich:panelBar binding="#{homeBean.newsItems}"/>
       </body>
       </html>
      </f:view>
      


      Facelet (home.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">
       <head>
       <title>
       </title>
       </head>
       <body>
       <h2>home.xhtml</h2>
       <rich:panelBar binding="#{homeBean.newsItems}"/>
       </body>
      </html>