2014-06-26 66 views
0

我有一個應用程序在JSF2和Icefaces3中實現,其中我在樣式表應用程序中遇到問題。在登錄時,樣式表正確應用,但在每次重定向之後,它不再正確。此問題只能在IE瀏覽器中找到。在我刪除重定向標記()時,在faces-config.xml文件中,除了URL沒有更改並且沒有考慮到標記:我添加到強制兼容模式之外,一切都正常。對於樣式的進口我已經嘗試了幾種公式:在IE8 Web瀏覽器上的Icefaces 3應用程序中重定向後不應用CSS樣式

<!-- formule 1--> 
    <ice:outputStyle 
      href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css" 
      rel="stylesheet" type="text/css" /> 

    <!-- formule 2--> 
    <ice:outputStyle 
       href="#{request.contextPath}/resources/css/global.css" 
       rel="stylesheet" type="text/css" /> 

    <!-- formule 3--> 
    <ice:outputStyle 
       href="/resources/css/global.css" 
       rel="stylesheet" type="text/css" /> 

    <!-- formule 4--> 
    <link href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css" rel="styleSheet" type="text/css"/> 

    <!-- formule 5--> 
    <link href="#{request.contextPath}/resources/css/global.css" rel="styleSheet" type="text/css"/> 

faces-config.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" 
    version="2.0"> 

    <application> 
     <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver> 
     <variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver> 
     <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> 
    </application> 

    <managed-bean> 
     <managed-bean-name>renderManager</managed-bean-name> 
     <managed-bean-class>com.icesoft.faces.async.render.RenderManager</managed-bean-class> 
     <managed-bean-scope>application</managed-bean-scope> 
    </managed-bean> 

    <factory> 
     <exception-handler-factory> 
      com.omb.exception.CustomExceptionHandlerFactory 
     </exception-handler-factory> 
    </factory> 

    <navigation-rule> 
     <from-view-id>*</from-view-id> 
     <navigation-case> 
      <from-outcome>homeHotel</from-outcome> 
      <to-view-id>/pages/home/home.xhtml</to-view-id> 
      <redirect /> 
     </navigation-case> 

     <navigation-case> 
      <from-outcome>disconnect</from-outcome> 
      <to-view-id>/login.xhtml</to-view-id> 
      <redirect /> 
     </navigation-case> 

     <navigation-case> 
      <from-outcome>error</from-outcome> 
      <to-view-id>/pages/errors/technicalError.xhtml</to-view-id> 
      <redirect /> 
     </navigation-case> 

     <navigation-case> 
      <from-outcome>sessionExpired</from-outcome> 
      <to-view-id>login.xhtml</to-view-id> 
     </navigation-case> 
    </navigation-rule> 

</faces-config> 

的web.xml:

<?xml version="1.0"?> 

<!DOCTYPE web-app PUBLIC 
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "http://java.sun.com/dtd/web-app_2_3.dtd"> 

<web-app> 

    <display-name>MyApplication</display-name> 
    <description>MyApplication</description> 

    <!-- Without this param upload does not work at 1st time with IceFaces 3.3.0 --> 
    <context-param> 
     <param-name>org.icefaces.mandatoryResourceConfiguration</param-name> 
     <param-value>all</param-value> 
    </context-param> 

    <context-param> 
     <param-name>facelets.FACELETS_LIBRARIES</param-name> 
     <param-value>/pages/templates/tags.taglib.xml</param-value> 
    </context-param> 

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/appCtx/**/*applicationContext*.xml 
     </param-value> 
    </context-param> 


    <!-- Facelet Config --> 
    <!-- <context-param> <param-name>javax.faces.application.CONFIG_FILES</param-name> 
     <param-value> /WEB-INF/faces-config-application-beans.xml, /WEB-INF/faces-config-navigation.xml 
     </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>facelets.DEVELOPMENT</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> 
     <param-value>-1</param-value> 
    </context-param> 

    <context-param> 
     <param-name>com.icesoft.faces.standardRequestScope</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <!-- Specifies to the ICEfaces framework whether to support multiple views 
     of a single application from the same browser. When running in a Portlet 
     environment, this parameter must be set to true. --> 
    <context-param> 
     <param-name>com.icesoft.faces.concurrentDOMViews</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <!-- Specifies to the ICEfaces framework that synchronous update mode is 
     to be used. By default, ICEfaces uses asynchronous update mode to support 
     server-initiated updates (AJAX push). Setting to true will enable synchronous 
     update mode and disable AJAX push features. --> 
    <context-param> 
     <param-name>com.icesoft.faces.synchronousUpdate</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <!-- Specifies to the ICEfaces framework whether to compress the server-side 
     DOM representation after each response. This saves a considerable amount 
     of of memory per client. However, since this is decompressed/compressed for 
     every update, it may not bring significant memory savings to applications 
     that make frequent use of AJAX push. --> 
    <context-param> 
     <param-name>com.icesoft.faces.compressDOM</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <!-- Specifies the amount of time in milliseconds that the bridge will wait 
     for a response from the server for a user-initiated request before declaring 
     the connection lost. Un-comment and change the default value, if necessary. --> 
    <context-param> 
     <param-name>com.icesoft.faces.connectionTimeout</param-name> 
     <param-value>300000</param-value> 
    </context-param> 


    <!-- Specifies the amount of time in milliseconds that an idle asynchronous 
     blocking connection should be held open before being released. Normally, 
     the blocking connection is closed and re-opened with every communication 
     to the browser, such as user interaction or a heartbeat ping. The purpose 
     of this setting is to remove the possibility of threads being held blocked 
     for a long duration on a dead or completely inactive client connection. This 
     value should be longer than the heartbeat interval to avoid unnecessary network 
     traffic. Un-comment and change the default value, if necessary. --> 
    <context-param> 
     <param-name> 
      com.icesoft.faces.blockingConnectionTimeout 
     </param-name> 
     <param-value>90000</param-value> 
    </context-param> 


    <!-- Specifies the amount of time in milliseconds between heartbeat messages. 
     Un-comment and change the default value, if necessary. --> 
    <context-param> 
     <param-name>com.icesoft.faces.heartbeatInterval</param-name> 
     <param-value>50000</param-value> 
    </context-param> 


    <!-- Specifies how many consecutive heartbeat connection attempts may fail 
     before the connection is considered lost. Un-comment and change the default 
     value, if necessary. --> 
    <context-param> 
     <param-name>com.icesoft.faces.heartbeatRetries</param-name> 
     <param-value>2</param-value> 
    </context-param> 


    <!-- Specifies the number of milliseconds that a heartbeat request waits 
     for a successful response before it is considered timed out. Un-comment and 
     change the default value, if necessary. --> 
    <context-param> 
     <param-name>com.icesoft.faces.heartbeatTimeout</param-name> 
     <param-value>60000</param-value> 
    </context-param> 


    <!-- Specifies a page URI to redirect the client to when an asynchronous 
     connection is lost. The parameter value must be surrounded by single quotes. 
     Un-comment and change the default value, if necessary. --> 
    <context-param> 
     <param-name> 
      com.icesoft.faces.connectionLostRedirectURI 
     </param-name> 
     <param-value>login.xhtml</param-value> 
    </context-param> 

    <context-param> 
     <param-name> 
      com.icesoft.faces.sessionExpiredRedirectURI 
     </param-name> 
     <param-value>login.xhtml</param-value> 
    </context-param> 

    <context-param> 
     <param-name>com.icesoft.faces.blockUIOnSubmit</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <context-param> 
     <param-name>org.icefaces.ace.fileEntry.requireJavascript</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <context-param> 
     <param-name>log4jConfigLocation</param-name> 
     <param-value>classpath:log4j.properties</param-value> 
    </context-param> 

    <context-param> 
     <param-name>log4jExposeWebAppRoot</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_DEVELOPMENT</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <filter> 
     <filter-name>springFilter</filter-name> 
     <filter-class> 
      org.springframework.web.filter.RequestContextFilter 
     </filter-class> 
    </filter> 

    <filter> 
     <filter-name>openSessionInViewFilter</filter-name> 
     <filter-class> 
      org.springframework.orm.hibernate3.support.OpenSessionInViewFilter 
     </filter-class> 
     <init-param> 
      <param-name>singleSession</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </filter> 

    <filter-mapping> 
     <filter-name>openSessionInViewFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <filter-mapping> 
     <filter-name>springFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <!-- <filter-mapping> <filter-name>loggedInFilter</filter-name> <url-pattern>/pages/*</url-pattern> 
     </filter-mapping> --> 

    <!-- SPRING --> 
    <listener> 
     <listener-class> 
      org.springframework.web.util.Log4jConfigListener 
     </listener-class> 
    </listener> 

    <listener> 
     <listener-class> 
      org.springframework.web.context.ContextLoaderListener 
     </listener-class> 
    </listener> 

    <listener> 
     <listener-class> 
      org.springframework.web.context.request.RequestContextListener 
     </listener-class> 
    </listener> 

    <listener> 
     <listener-class> 
      org.springframework.web.util.IntrospectorCleanupListener 
     </listener-class> 
    </listener> 

    <!-- Listener d'initialisation de l'application --> 
    <listener> 
     <listener-class>com.omb.listeners.MyServletContextListener</listener-class> 
    </listener> 

    <!-- Faces Servlet --> 
    <servlet> 
     <servlet-name>Faces Servlet</servlet-name> 
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet> 
     <servlet-name>Resource Servlet</servlet-name> 
     <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</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> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>/icefaces/*</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Resource Servlet</servlet-name> 
     <url-pattern>/xmlhttp/*</url-pattern> 
    </servlet-mapping> 

    <session-config> 
     <session-timeout>60</session-timeout> 
    </session-config> 

    <!-- Welcome files --> 
    <welcome-file-list> 
     <welcome-file>login.xhtml</welcome-file> 
    </welcome-file-list> 

    <error-page> 
     <error-code>500</error-code> 
     <location>/pages/error.jsp</location> 
    </error-page> 
    <error-page> 
     <exception-type>java.lang.RuntimeException</exception-type> 
     <location>/pages/error.jsp</location> 
    </error-page> 
</web-app> 

login.xhtml:

<!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:ice="http://www.icesoft.com/icefaces/component" 
    xmlns:ace="http://www.icefaces.org/icefaces/components" 
    xmlns:ui="http://java.sun.com/jsf/facelets"> 
<h:head> 
    <!-- ice:outputStyle href="/resources/css/global.css" rel="stylesheet" 
     type="text/css" /--> 
    <ice:outputStyle 
     href="#{facesContext.externalContext.requestContextPath}/resources/css/myCss.css" 
     rel="stylesheet" type="text/css" /> 
</h:head> 

<h:body onload='document.getElementById("loginForm:login").focus()'> 
    <ice:form id="loginForm"> 

     <h:panelGroup id="page" styleClass="mainMaster" layout="block"> 
      <h:panelGroup id="header" styleClass="header" layout="block"> 
       <h:panelGroup styleClass="logo" layout="block"> 
        <ice:graphicImage styleClass="imgLogo" 
         value="/resources/images/common/logo/Logo.png" /> 
       </h:panelGroup> 
      </h:panelGroup> 
      <h:panelGroup id="content" styleClass="mainContent" layout="block"> 
       <h:panelGroup styleClass="content" layout="block"> 
        <h:panelGroup styleClass="txtLogin" layout="block"> 
         <span><ice:outputLabel value="#{msg['login']}" /> : * </span> 
         <ice:inputText value="#{loginBean.login}" id="login" /> 
        </h:panelGroup> 
        <h:panelGroup styleClass="txtLogin" layout="block"> 
         <span><ice:outputLabel value="#{msg['password']}" /> : *</span> 
         <ice:inputSecret value="#{loginBean.password}" 
          action="#{loginBean.doLogin}" /> 
         <br /> 
         <span></span> 
        </h:panelGroup> 
        <h:panelGroup styleClass="txtLogin" layout="block"> 
         <span></span> 
         <ice:commandButton id="loginButton" value="#{msg['log.on']}" 
          action="#{loginBean.doLogin}" /> 
        </h:panelGroup> 
        <h:panelGroup layout="block"> 
         <ace:panel style="border: 0px;"> 
          <ace:message id="formMsg" for="loginForm" initEffect="slide" /> 
         </ace:panel> 
        </h:panelGroup> 
       </h:panelGroup> 
      </h:panelGroup> 
      <h:panelGroup id="footer" styleClass="footer" layout="block"> 
       <ui:insert name="footer"> 
        <ui:include src="/pages/layer/footer/footer.xhtml" /> 
       </ui:insert> 
      </h:panelGroup> 
     </h:panelGroup> 
    </ice:form> 
</h:body> 
</html> 

template.xhtml:

<?xml version="1.0" encoding="UTF-8"?> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:ice="http://www.icesoft.com/icefaces/component"> 

<h:head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> 
    <meta http-equiv="X-UA-Compatible" content="IE=8" /> 
    <title><ui:insert name="title">MyApplication</ui:insert></title> 
    <ice:outputStyle href="/xmlhttp/css/xp/xp.css" rel="stylesheet" 
     type="text/css" /> 
    <!-- ice:outputStyle href="#{request.contextPath}/resources/css/global.css" rel="stylesheet" type="text/css" /--> 
    <ice:outputStyle 
     href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css" 
     rel="stylesheet" type="text/css" /> 
    <script type="text/javascript"> 
     jsf.ajax.addOnError(function(data) { 
      if (data.responseText.indexOf("SessionExpiredException") > 0) { 
       window.location = "login.xhtml"; 
      } 
     }); 

     // French initialization 
     ice.ace.locales['fr'] = { 
      closeText : 'Fermer', 
      prevText : 'Précédent', 
      nextText : 'Suivant', 
      currentText : 'Courant', 
      monthNames : [ 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 
        'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 
        'Novembre', 'Décembre' ], 
      monthNamesShort : [ 'Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 
        'Jul', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc' ], 
      dayNames : [ 'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 
        'Vendredi', 'Samedi' ], 
      dayNamesShort : [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ], 
      dayNamesMin : [ 'Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa' ], 
      weekHeader : 'Sm', 
      dateFormat : 'dd/mm/yy', 
      firstDay : 1, 
      isRTL : false, 
      showMonthAfterYear : false, 
      yearSuffix : '' 
     }; 
    </script> 
</h:head> 

<h:body> 
    <h:panelGroup id="page" styleClass="mainMaster" layout="block"> 
     <h:panelGroup id="header" styleClass="header" layout="block"> 
      <ui:insert name="header"> 
       <ui:include 
        src="/pages/layer/header/#{contextBean.templateHeaderName}" /> 
      </ui:insert> 
     </h:panelGroup> 
     <h:panelGroup id="headerMenu" styleClass="menu" layout="block"> 
      <ui:insert name="buttons"> 
       <ui:include 
        src="/pages/layer/menu/#{contextBean.templateMenuButtonName}" /> 
      </ui:insert> 
     </h:panelGroup> 
     <h:panelGroup id="main" styleClass="mainContent" layout="block"> 
      <h:panelGroup id="content" styleClass="content" layout="block"> 
       <h:panelGroup layout="block" 
        rendered="#{not facesContext.validationFailed and not empty facesContext.messageList}"> 
        <h:messages id="psuedoGlobalMessages" globalOnly="true" 
         infoStyle="color:blue" errorStyle="color:red" 
         warnClass="color:orange" showDetail="false" showSummary="true" /> 
       </h:panelGroup> 
       <ui:insert name="content" /> 
      </h:panelGroup> 
     </h:panelGroup> 
     <h:panelGroup id="footer" styleClass="footer" layout="block"> 
      <ui:insert name="footer"> 
       <ui:include src="/pages/layer/footer/footer.xhtml" /> 
      </ui:insert> 
     </h:panelGroup> 
    </h:panelGroup> 
</h:body> 
</html> 

回答

0

我找到了解決辦法:

  • 首先,我改變了login.xhtml頁的實施,使它也包括我的facelet模板。

  • 二:我添加了DOCTYPE應答器在的template.xhtml

現在sheetstyle在所有網頁應用的開始。

有關兼容性模式i製成,其設置屬性的HttpFilter:

((HttpServletResponse) response).setHeader("X-UA-Compatible", this.xuacompatible); 
相關問題