0

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

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

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

4

2 回答 2

0

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

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

而不是这样的:

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

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

于 2013-12-24T12:42:16.357 回答
0

你试过了吗:

用户界面页面(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);
    }
于 2013-04-21T01:54:34.240 回答