spring - 为什么 RichFaces 4 组件无法正确渲染?

标签 spring jsf jboss richfaces

我在 JBoss EAP 6.1 上使用 RichFaces 4 以及 JSF、Spring 和 Spring Web Flow,从 JBoss EAP 5.1 上的相应技术(例如 RichFaces 3.3)迁移而来。

问题在于 rich: 命名空间中的任何组件或控件都会为其生成一些 HTML,但当它在浏览器中呈现时,它看起来与 RichFaces 展示站点上的相应组件完全不同。似乎有 CSS 和图像文件应该与 RichFaces jar 文件捆绑在一起,但浏览器无法找到它们。下面的屏幕截图。 screen shot 1 .

作为测试,我选择了一个简单的控件,即 rich:collapsiblePanel,并将展示网站中的示例代码粘贴到我们应用程序的测试页面中。可折叠面板出现,但看起来与演示网站上的面板完全不同。下面的屏幕截图。 screen shot 2 .

我在多个浏览器(IE、Firefox 和 Chrome)和多个 rich: 组件(例如 rich:extendedDataTable、rich:tabPanel、rich:calendar)中得到相同的结果,所以我认为这指向一个库或配置问题。

下面是我正在使用的库的列表。

aopalliance-1.0.jar
aspectjweaver.jar
cglib-nodep-2.2.2.jar
commons-beanutils-1.8.3.jar
commons-codec-1.5.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-lang-2.6.jar
commons-logging-1.1.jar
cssparser-0.9.5.jar
guava-r09.jar
jdom.jar
log4j-1.2.16.jar
org.springframework.binding-2.3.2.RELEASE.jar
org.springframework.faces-2.3.2.RELEASE.jar
org.springframework.js-2.3.2.RELEASE.jar
org.springframework.js.resources-2.3.2.RELEASE.jar
org.springframework.webflow-2.3.2.RELEASE.jar
poi-3.8-20120326.jar
richfaces-components-api-4.3.2.Final-redhat-1.jar
richfaces-components-ui-4.3.2.Final-redhat-1.jar
richfaces-core-api-4.3.2.Final-redhat-1.jar
richfaces-core-impl-4.3.2.Final-redhat-1.jar
sac-1.3.jar
spring-aop-3.2.0.RELEASE.jar
spring-aspects-3.2.0.RELEASE.jar
spring-beans-3.2.0.RELEASE.jar
spring-context-3.2.0.RELEASE.jar
spring-context-support-3.2.0.RELEASE.jar
spring-core-3.2.0.RELEASE.jar
spring-expression-3.2.0.RELEASE.jar
spring-instrument-3.2.0.RELEASE.jar
spring-instrument-tomcat-3.2.0.RELEASE.jar
spring-jdbc-3.2.0.RELEASE.jar
spring-jms-3.2.0.RELEASE.jar
spring-orm-3.2.0.RELEASE.jar
spring-oxm-3.2.0.RELEASE.jar
spring-security-acl-3.1.3.RELEASE.jar
spring-security-aspects-3.1.3.RELEASE.jar
spring-security-cas-3.1.3.RELEASE.jar
spring-security-config-3.1.3.RELEASE.jar
spring-security-core-3.1.3.RELEASE.jar
spring-security-crypto-3.1.3.RELEASE.jar
spring-security-ldap-3.1.3.RELEASE.jar
spring-security-openid-3.1.3.RELEASE.jar
spring-security-remoting-3.1.3.RELEASE.jar
spring-security-taglibs-3.1.3.RELEASE.jar
spring-security-web-3.1.3.RELEASE.jar
spring-struts-3.2.0.RELEASE.jar
spring-test-3.2.0.RELEASE.jar
spring-tx-3.2.0.RELEASE.jar
spring-web-3.2.0.RELEASE.jar
spring-webmvc-3.2.0.RELEASE.jar
spring-webmvc-portlet-3.2.0.RELEASE.jar

这是我的 web.xml,仅更改了少数部分以实现匿名(app-servlet.xml 和 com.app.class)。

<?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      /WEB-INF/app-servlet.xml
    </param-value>
  </context-param>
  <filter>
    <filter-name>charEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>charEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <context-param>
    <param-name>org.richfaces.skin</param-name>
    <param-value>DEFAULT</param-value>
  </context-param>

  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
  </context-param>

  <filter>
        <filter-name>RewriteRequestHeaderFilter</filter-name>
        <filter-class>com.app.class</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>RewriteRequestHeaderFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value></param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
  </servlet-mapping>
  <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>

  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

我还查看了 this questionthis question这似乎是相关的,但我找不到任何信息来帮助解决我的问题。

有什么建议吗?

最佳答案

原来是 Spring 配置问题。如果您使用 Spring 和/或 Spring Web Flow,请检查配置文件中是否有以下代码。请注意,这些只是代码片段,而不是完整的配置文件。

webflow-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:webflow="http://www.springframework.org/schema/webflow-config"
       xmlns:faces="http://www.springframework.org/schema/faces"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/webflow-config 
           http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
           http://www.springframework.org/schema/faces 
           http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">

webmvc-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:faces="http://www.springframework.org/schema/faces"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">

    <faces:resources />

    <!-- Needed for RichFaces! -->
    <bean name="richfacesResourceHandler" class="org.springframework.faces.webflow.JsfResourceRequestHandler" />
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="order" value="0" />
        <property name="mappings">
            <value>
                  /rfRes/**=richfacesResourceHandler
            </value>
        </property>
    </bean>

关于spring - 为什么 RichFaces 4 组件无法正确渲染?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19643529/

相关文章:

java - 参数调用中的大括号。 >> 这是什么意思? | Spring 3 和 GWT

java - JSF 中的 "for"循环

带有 SelectItems 的 JSF 2.0 selctOneMenu

jboss - 如何使用 hawtio 之类的工具停止 Camel 的飞行中交换?

java - 将 Spring Roo 应用程序转换为 JBoss 6 应用程序

jboss - 如何在jboss中使用saml picketlink进行身份验证?

java - 不支持从 varbinary 到 BLOB 的转换

java - Spring Boot 千分尺计数取消

Spring Boot - 过滤异常处理程序

java - 在 hibernate +Java 中迭代对象列表时出错?