0

I am new with jsf and rich faces. i am following there live demo and trying create a simple menu. but it is not working. I am using jboss7.1 and jsf 2.1 with ric 4.3.4

menu.xmhtl

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
<h:head></h:head>
<h:body>
    <ui:composition>
        <h:form>
            <rich:toolbar height="26px">
                <rich:dropDownMenu   mode="ajax">
                    <f:facet name="label">
                        <h:panelGroup>
                            <h:outputText value="File" />
                        </h:panelGroup>
                    </f:facet>
                    <rich:menuItem label="hello" action="hello" />
                    <rich:menuSeparator id="menuSeparator11" />
                    <rich:menuItem label="Open" action="AddStudent" />
                </rich:dropDownMenu>

                <rich:dropDownMenu mode="ajax">
                    <f:facet name="label">
                        <h:panelGroup>
                            <h:outputText value="File" />
                        </h:panelGroup>
                    </f:facet>
                    <rich:menuItem label="hello" action="hello" />
                    <rich:menuItem label="Open" action="AddStudent" />
                </rich:dropDownMenu>
            </rich:toolbar>
        </h:form>

    </ui:composition>
</h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">

    <display-name>helloRich</display-name>
    <welcome-file-list>
        <welcome-file>hello.xhtml</welcome-file>
    </welcome-file-list>

    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</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>*.xhtml</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
</web-app>

and these are my jar in lib directory

cssparser-0.9.5.jar
guava-r08.jar 
jstl-1.2.jar        
richfaces-components-api-4.3.4.Final.jar       
richfaces-components-ui-4.3.4.Final.jar      
richfaces-core-api-4.3.4.Final.jar          
richfaces-core-impl-4.3.4.Final.jar 
sac-1.3.jar

i have no idea what i am missing here.. any help would be helpfull.. My output enter image description here

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
  • You're missing `` and `` tags. What happens if you add them? Guess: you're not loading the RF javascript files? – mabi Jan 20 '14 at 11:15
  • no m not using any javascript.. just a simple menu.. – Shankari vatsalkumar Jan 20 '14 at 11:21
  • Richfaces uses javascript extensively, check if your page loads "packed.js" and "jsf.js". Even if *you* don't load any (custom) javascript, these files need to be present for about anything to work. – mabi Jan 20 '14 at 11:33

1 Answers1

1

You need to get rid of the <ui:composition> on your page.

By definition everything declared outside <ui:composition> tags is ignored by the JSF runtime. That includes the <h:head> and <h:body> tags you have there. The problem that creates is that the <h:head/> tag is necessary for JSF to be able to include the javascript baggage required to render the components properly. This is the problem you're experiencing.

Seeing as you're not actually using the templating power of the <ui:composition/>, you can safely remove it to get results.

Related:

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104