2013-10-28 94 views
2

我在JBoss EAP 6.1上使用RichFaces 4以及JSF,Spring和Spring Web Flow,從JBoss EAP 5.1上的相應技術(例如RichFaces 3.3)進行遷移。爲什麼RichFaces 4組件不能正確渲染?

問題是rich:namespace中的任何組件或控件都會爲它生成一些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這似乎是相關的,但我無法找到任何信息,以幫助解決我的問題。

有什麼建議嗎?

+0

你有SSCCE網頁? – SJuan76

+0

它沒有加載清晰的richfaces的CSS,那麼在Chrome中點擊鼠標右鍵並查看元素來查看css是否已加載並可以訪問? – LMG

回答

2

原來這是一個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> 
+0

免責聲明:我的同事明白這一點。我只是貼出來,以防其他人遇到同樣的問題。 –