【问题标题】:PrimeFaces , themeroller, error when theme changedPrimeFaces,themeroller,主题更改时出错
【发布时间】:2013-04-13 21:39:54
【问题描述】:

我在 pom.xml 中添加了 all-themes.jar,它适用于 web.xml 中的一个主题。

<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)

我尝试了三种方法,一种来自展示柜,另一种来自 primefaces 书籍,最后一种来自一些教程。我总是得到同样的错误。我什至完全复制了示例中的代码,但仍然没有,我认为我在 web.xml 或 faces-config.xml 中缺少一些设置......有人可以帮我吗? 十分感谢! 我使用 Spring 3.1、primefaces 3.5、jsf 2.0.7。

编辑: - 当我导航到另一个页面但不更改起始主题时它可以工作 - 我可以更改主题,但是当主题更改并导航到另一个页面时,出现上述错误 - 默认主题是什么无关紧要,它会加载,只要默认主题没有更改,我就可以浏览整个应用程序

【问题讨论】:

    标签: spring jsf primefaces themeroller


    【解决方案1】:

    你试过了吗:

    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);
        }
    

    【讨论】:

    • 嗨 RongNK,这正是我在代码中采用的方法。我尝试了两个有状态示例(ajax 和 page refres)以及 PrimeFaces Cookbook 中的一个。总是同样的错误,基本上你可以从这一行看到:javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-" library "primefaces-?? ?”找不到jar,但只有在刷新页面时。我的 pom.xml 中有 all-themes.jar
    • 我的意思是jar在那里但是新主题名称的参数没有传递给新视图...
    • 你使用Maven,所以你参考:forum.primefaces.org/viewtopic.php?f=9&t=18928
    • 我使用的是 Maven,但是从上面的错误中可以看出,它找到了 jar。但是当我导航到另一个视图时,新主题的值丢失了primefaces-,所以它就像由于某种原因不保持视图之间的值一样。
    【解决方案2】:

    完全遇到了同样的问题 - themeSwitcher 不在表单元素内,所以只要我不进行导航,它就可以工作。然后它就因为空字符串被设置为当前主题而分手了——这就是我收到消息的原因:

    javax.faces.FacesException:加载主题时出错,找不到“primefaces-”库的“theme.css”资源

    而不是类似:

    javax.faces.FacesException:加载主题时出错,找不到“primefaces-cupertino”库的“theme.css”资源

    所以,如果你有这个问题,首先检查&lt;p:themeSwitcher&gt; 是否被&lt;h:form&gt; 元素包围。

    【讨论】:

      猜你喜欢
      • 2016-06-17
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 1970-01-01
      • 1970-01-01
      • 2020-03-12
      相关资源
      最近更新 更多