0
votes

I am using JSF 2 and RichFaces in Tomcat. I am a beginner and trying out a page I found here, but the page is just blank (contents not being rendered). I try to add the Facelets 1.1 libraries and the page is rendered without a problem. However, I read somewhere that with JSF 2, Facelets libraries are not necessary as they are included by default. Also, when I add the Facelets libraries, other pages are being affected where I start getting a message like "library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head" for a page that was working ok without the libraries. I also included the following libraries in my /WEB-INF/lib directory:

  1. richfaces-api-3.3.3.Final.jar
  2. richfaces-impl-3.3.3.Final.jar
  3. richfaces-impl-jsf2-3.3.3.Final.jar
  4. richfaces-ui-3.3.3.Final.jar
  5. jstl.jar
  6. standard.jar

For simplicity, my code is here (some sections removed so that it is not too long).

NB:When i insert some plain text inside h:form or h:panelGrid, it is rendered without a problem.

<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
    .cols {
        vertical-align: top;
        }
</style>
<h:form id="form">
    <h:panelGrid columns="2" columnClasses="cols,cols" width="400">
        <rich:panelMenu style="width:200px" mode="ajax"
            iconExpandedGroup="disc" iconCollapsedGroup="disc"
            iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
            iconCollapsedTopGroup="chevronDown">
            <rich:panelMenuGroup label="Group 1">
                <rich:panelMenuItem label="Item 1.1"
                    action="#{panelMenu.updateCurrent}">
                    <f:param name="current" value="Item 1.1" />
                </rich:panelMenuItem>
                <rich:panelMenuItem label="Item 1.2"
                    action="#{panelMenu.updateCurrent}">
                    <f:param name="current" value="Item 1.2" />
                </rich:panelMenuItem>
                <rich:panelMenuItem label="Item 1.3"
                    action="#{panelMenu.updateCurrent}">
                    <f:param name="current" value="Item 1.3" />
                </rich:panelMenuItem>
            </rich:panelMenuGroup>
        </rich:panelMenu>
        <rich:panel bodyClass="rich-laguna-panel-no-header">
            <a4j:outputPanel ajaxRendered="true">
                <h:outputText value="#{panelMenu.current} selected" id="current" />
            </a4j:outputPanel>
        </rich:panel>
    </h:panelGrid>
</h:form>

2

2 Answers

0
votes

Did you add jsf 2.0 libraries?

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>javax.faces-api</artifactId>
  <version>2.1</version>
  <scope>provided</scope>

And configured your web xml like this?

<servlet>

<servlet-name>Faces Servlet</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1</load-on-startup>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>*.jsf</url-pattern>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>/*</url-pattern>

0
votes

There's library conflict in your libraries, but I'm not sure it is related to the problem you're referring to.

You should NOT have both of the following libraries in your project:

  • richfaces-impl-3.3.3.Final.jar
  • richfaces-impl-jsf2-3.3.3.Final.jar

They include similar set of classes. If you're using JSF 2, remove richfaces-impl-3.3.3.Final.jar from your classpath.