java 加载主题时出错,找不到primefaces主题库的“theme.css”资源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29025709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 14:33:43  来源:igfitidea点击:

Error loading theme, cannot find "theme.css" resource of primefaces theme library

javajsfprimefacesthemes

提问by Diana

I use primefaces-5.1.jar andjavax.faces-2.2.0.jar(i got some error forjavax.faces-2.2.9.jar`)

我使用primefaces-5.1.jar andjavax.faces-2.2.0.jar (i got some error forjavax.faces-2.2.9.jar`)

Put this also in web.xml

把这个也放进去 web.xml

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{Helper.theme}</param-value>
</context-param>

then i got error:

然后我得到了错误:

Error loading theme, cannot find "theme.css" resource of "primefaces-bootstrap" library

javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-bootstrap" library
    at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:134) ~[primefaces-5.1.jar:5.1]
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:81) ~[primefaces-5.1.jar:5.1]
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) ~[javax.faces-2.2.0.jar:2.2.0]

But when i use javax.faces-2.1.25.jarthe error above is solved but get another error:

但是当我使用javax.faces-2.1.25.jar上面的错误解决了但又出现了另一个错误:

com.sun.faces.context.flash.ELFlash getCurrentFlashManager
SEVERE: JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.

My question is what compatible library for primefaces-5.1.jar?

我的问题是什么兼容库primefaces-5.1.jar

Thanks

谢谢

回答by ?ɑ??????

Put Primefaces Theme Maven dependecy into your pom.xml

将 Primefaces Theme Maven 依赖放入你的 pom.xml

<dependency>
  <groupId>org.primefaces.extensions</groupId>
  <artifactId>all-themes</artifactId>
  <version>1.0.8</version>
  <scope>compile</scope>
</dependency>

Official documentation suggests use the 10.0.10 version of Primefaces themes, requesting add their own repository, which is not working properly and I was still receiving an error and this version of themes is not available in the Maven Central Repository.

官方文档建议使用 10.0.10 版本的 Primefaces 主题,请求添加自己的存储库,但它无法正常工作,我仍然收到错误消息,并且该版本的主题在 Maven 中央存储库中不可用。

After much research without an effective solution, I had need to opt to the last version of Maven repository whose is available only up to version 1.0.8. but my project still getting the following warning:

在没有有效解决方案的情况下进行大量研究后,我不得不选择最新版本的 Maven 存储库,该版本仅适用于 1.0.8 版。但我的项目仍然收到以下警告:

WARNING: JSF1064:Unable to find or serve resource, images/ui-bg_highlight-hard_70_000000_1x100.png, from library, primefaces-bootstrap.

WARNING: JSF1064:N?o foi possível encontrar ou fornecer o recurso, images/ui-bg_highlight-hard_70_000000_1x100.png, pela biblioteca, primefaces-bootstrap.

警告:JSF1064:无法找到或提供资源,images/ui-bg_highlight-hard_70_000000_1x100.png,来自库,primefaces-bootstrap。

警告:JSF1064:N?o foi possível encontrar ou fornecer o recurso、images/ui-bg_highlight-hard_70_000000_1x100.png、pela biblioteca、primefaces-bootstrap。

Thinking a little bit I found a simple solution that solves the bootstrap theme problem.

稍微思考一下,我找到了一个简单的解决方案,可以解决引导程序主题问题。

The solution is :

解决办法是:

  • Pass a new path to the image that is missed
  • Replace the property backgroundof ui-widget-shadowcss class
  • 将新路径传递给丢失的图像
  • 更换物业backgroundUI小部件阴影CSS类

Steps:

脚步:

  1. Download missed image : | Link 1| Link 2| Link 3|

    • All links refer to: ui-bg_highlight-hard_70_000000_1x100.png
  2. Place this image in a folder of your project (Suggestion: /resources/images/)

  3. Overwrite only the property that has the invalid reference to the image
  1. 下载丢失的图像:| 链接 1| 链接 2| 链接 3|

    • 所有链接参考:ui-bg_highlight-hard_70_000000_1x100.png
  2. 在这张画项目的文件夹中(建议:/resources/images/

  3. 仅覆盖对图像具有无效引用的属性

Use the following code:

使用以下代码:

.ui-widget-shadow {
   background-image: url("images/ui-bg_highlight-hard_70_000000_1x100.png.jsf") !important;
}

That problem is discussed in:

该问题在以下内容中讨论:

I hope this helps ! ;-)

我希望这有帮助 !;-)

回答by conteh

Add dependency to pom.xml

将依赖添加到 pom.xml

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>5.0</version>
</dependency>
<dependency>  
    <groupId>org.primefaces.themes</groupId>  
    <artifactId>cupertino</artifactId>  
    <version>1.0.8</version>  
</dependency>

Add configuration to web.xml

将配置添加到 web.xml

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{LayoutBean.applicationTheme}</param-value>
</context-param>

Create an application scoped eager bean to load when the JSF application loads

在 JSF 应用程序加载时创建一个应用程序范围的 Eager bean 来加载

@ManagedBean(name = "LayoutBean", eager = true)
@ApplicationScoped
public class LayoutBean {

    private String theme = "cupertino";

    public String getApplicationTheme() {
        return theme;
    }
}

回答by Deoxyseia

  • Make sure that the dependency is well added in pom.xml (Add manually jar to maven local repository if this is premium theme, more info here)

    <dependency>
      <groupId>org.primefaces.themes</groupId>
      <artifactId>{theme-name-here}</artifactId>
      <version>{version-here}</version>
    </dependency>
    
  • Add the correct configuration in web.xml for use this theme.

    <context-param>
      <param-name>primefaces.THEME</param-name>
      <param-value>#{theme-name-here}</param-value>
    </context-param>
    
  • 确保在 pom.xml 中很好地添加了依赖项(如果这是高级主题,请手动将 jar 添加到 Maven 本地存储库,更多信息在这里

    <dependency>
      <groupId>org.primefaces.themes</groupId>
      <artifactId>{theme-name-here}</artifactId>
      <version>{version-here}</version>
    </dependency>
    
  • 在 web.xml 中添加正确的配置以使用此主题。

    <context-param>
      <param-name>primefaces.THEME</param-name>
      <param-value>#{theme-name-here}</param-value>
    </context-param>
    

I had a case where everything was set up correctly but the message "Error loading theme, cannot find “theme.css” resource of primefaces theme library" still appeared. I solved it:

我有一个情况,一切都设置正确,但仍然出现消息“错误加载主题,找不到primefaces主题库的“theme.css”资源”。我解决了:

  • Project in Eclipse --> clean... --> Clean all projects
  • Right click in project --> refresh
  • Go to servers view --> right click in Tomcat installation --> Clean and Publish
  • Run app.
  • Eclipse 中的项目 --> 清理... --> 清理所有项目
  • 在项目中右击 --> 刷新
  • 转到服务器视图--> Tomcat 安装中的右键单击--> Clean and Publish
  • 运行应用程序。

This remove all cache files, works for me.

这删除了所有缓存文件,对我有用。

回答by Kukeltje

All recent versions of themes in the primefaces maven repository are compatible with 5.1

primefaces maven 存储库中所有最新版本的主题都与 5.1 兼容

回答by wieland.gmeiner

Did you include only the primefaces jar or the themes as well? E.g. using maven you need a dependency for primefaces and a dependency for the theme or all themes. I forgot the latter and got the same exception. Have a look here (scroll down to "Installation"): Primefaces/Themes

您是否只包含了primefaces jar 或主题?例如,使用 maven,您需要一个 Primefaces 的依赖项和一个主题或所有主题的依赖项。我忘记了后者并得到了同样的例外。看看这里(向下滚动到“安装”):Primefaces/Themes