【发布时间】:2014-01-20 10:52:47
【问题描述】:
我是 jsf 和丰富面孔的新手。我正在关注现场演示并尝试创建一个简单的菜单。但它不工作。我正在使用 jboss7.1 和 jsf 2.1 和 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>
这些是我在 lib 目录中的 jar
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
我不知道我在这里缺少什么..任何帮助都会有所帮助.. 我的输出
【问题讨论】:
-
您缺少
<h:head>和<h:body>标签。如果添加它们会发生什么?猜猜:你没有加载 RF javascript 文件? -
no m 没有使用任何 javascript.. 只是一个简单的菜单..
-
Richfaces 广泛使用 javascript,检查您的页面是否加载了“packed.js”和“jsf.js”。即使你不加载任何(自定义)javascript,这些文件也需要存在才能正常工作。