2013-04-20 23 views
0

我在pom.xml中添加了all-themes.jar,它在web.xml中的一個主題中正常工作。PrimeFaces,themeroller,當主題發生變化時出錯

<context-param> 
     <param-name>primefaces.THEME</param-name> 
     <param-value>excite-bike</param-value> 
</context-param> 

但是,當我在web.xml中使用的EL2.2

<context-param> 
     <param-name>primefaces.THEME</param-name> 
     <param-value>#{userSettingsController.currentTheme.name}</param-value> 
</context-param> 

聲明的主題動態得到它下面的錯誤與主題輥當我改變了這個主題在下拉列表中。

Apr 20, 2013 5:08:24 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/timetable] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'start' of flow 'teacher'] with root cause 
javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-" library 
    at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:130) 
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:92) 
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:829) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655) 
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399) 
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) 
    at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99) 
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) 
    at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80) 
    at org.springframework.faces.webflow.JsfView.render(JsfView.java:90) 
    at org.springframework.webflow.engine.ViewState.render(ViewState.java:296) 
    at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243) 
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:221) 
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:261) 
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169) 
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183) 
    at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:722) 

我嘗試了三種方法,一種來自showcase,另一種來自primefaces書,最後一種來自某個教程。我總是得到同樣的錯誤。我甚至完全像例子中那樣複製代碼,但仍然沒有任何結果,我假設我在web.xml或faces-config.xml中缺少一些設置...任何人都可以幫助我嗎? 非常感謝! 我使用Spring 3.1,primefaces 3.5,jsf 2.0.7。

編輯: - 它的工作原理,當我瀏覽到另一個頁面,但沒有改變首發主題 - 我可以改變的主題,但如果主題是改變,我導航到另一個網頁上面的錯誤 - 這並不重要是默認的主題,它會載入只要默認的主題沒有改變

回答

0

我可以瀏覽整個應用程序你嘗試:

UI頁面(XHTML,...):

    <p:themeSwitcher style="width: 200px" value="#{topBean.theme}" id="defaultSwitcher"> 
         <f:selectItem itemLabel="Choose Theme" itemValue="" /> 
         <f:selectItems value="#{topBean.themes}" /> 
         <p:ajax listener="#{topBean.saveTheme}" /> 
        </p:themeSwitcher> 

豆:

private Map<String, String> themes; 
    private String theme; 
    private GuestPreferences gp; 
    public TopBean(){ 
     theme = "eggplant"; 
    } 

    public Map<String, String> getThemes() { 
     return themes; 
    } 

    public String getTheme() { 
     return theme; 
    } 

    public GuestPreferences getGp() { 
     return gp; 
    } 

    public void setThemes(Map<String, String> themes) { 
     this.themes = themes; 
    } 

    public void setTheme(String theme) { 
     this.theme = theme; 
    } 

    public void setGp(GuestPreferences gp) { 
     this.gp = gp; 
    } 

    @PostConstruct 
    public void init() { 
     gp = new GuestPreferences(); 
     theme = gp.getTheme(); 
     themes = new TreeMap<String, String>(); 
     themes.put("Aristo", "aristo"); 
     themes.put("Black-Tie", "black-tie"); 
     ... 
    } 

    public void saveTheme() { 
     gp.setTheme(theme); 
    } 
+0

嗨RongNK,這正是我在我的代碼中採用的方法。我嘗試了兩個有狀態的例子(ajax和page refres),以及PrimeFaces Cookbook的例子。總是出現同樣的錯誤,基本上可以從這行看到:** javax.faces.FacesException:加載主題時出錯,找不到「primefaces-」庫的「theme.css」資源**「primefaces - ???」找不到罐子,但只有刷新頁面時才能找到。我有我的pom.xml中的所有themes.jar – Lukasz 2013-04-21 12:30:14

+0

我的意思是有jar,但新的主題名稱的參數不傳遞給新的視圖... – Lukasz 2013-04-21 12:51:45

+0

您使用Maven,所以你參考:http://論壇.primefaces.org/viewtopic.php?f = 9&t = 18928 – 2013-04-21 15:49:52

0

完全相同同樣的問題 - themeSwitcher是不是裏面的表單元素所以有人只要我沒有做導航工作。然後它分手了,因爲空字符串被設置爲當前主題 - 這就是爲什麼我得到的消息:

javax.faces.FacesException:加載主題時出錯,找不到「primefaces-」庫的「theme.css」資源

,而不是像這樣:

javax.faces.FacesException:錯誤加載主題,找不到 「primefaces庫比蒂諾」 「theme.css」 資源庫

所以,如果你有這個問題,首先全部檢查<p:themeSwitcher>是否包含<h:form>元素。

相關問題