通过primefaces在Primefaces 5.1中应用主题.主题不起作用 [英] Applying Theme in Primefaces 5.1 via primefaces.THEME doesn't work
问题描述
我正在尝试为PrimeFaces项目获取下载的Dark-Hive Themeroller主题,但无法弄清楚为什么它不会显示...查看html源代码,我总是看到Aristo主题,我相信是默认的PrimeFaces主题.我遵循了多个论坛建议,但必须将其发布到社区中-也许有人可以给我提示.
I am trying to get the downloaded Dark-Hive Themeroller theme for a PrimeFaces project going but can't figure out why it won't show...Looking into the html source code I always see Aristo theme, which I believe is the default PrimeFaces theme. I followed multiple forum suggestions but have to post this one into the community - maybe someone can give me a hint.
- /webapp/WEB-INF/lib/dark-hive.jar->从themeroller.org下载 并通过themeroller.osnode.com/themeroller转换为PF 主题
- /webapp/WEB-INF/templates/layout.xhtml->我的主模板,其中包含xmlns:h ="http://java.sun.com/jsf/html"命名空间属性以及标记
- /webapp/WEB-INF/resources
- /webapp/WEB-INF/web.xml
- /webapp/WEB-INF/faces-config.xml
- ...
- /webapp/WEB-INF/lib/dark-hive.jar -> downloaded from themeroller.org and converted with themeroller.osnode.com/themeroller into a PF theme
- /webapp/WEB-INF/templates/layout.xhtml -> my master template, which contains xmlns:h="http://java.sun.com/jsf/html" namespace attribute as well as tag
- /webapp/WEB-INF/resources
- /webapp/WEB-INF/web.xml
- /webapp/WEB-INF/faces-config.xml
- ...
我不会仅仅因为根据文档就输出PF主题就不需要输出任何CSS.
I don't output any CSS simply because according to the docs it's not needed for PF themes to work.
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>dark-hive</param-value>
</context-param>
请注意,我已将资源文件夹移至WEB-INF/.
Please note that I moved the resources folder into WEB-INF/.
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dark-hive</artifactId>
<version>1.0.8</version>
</dependency>
由于Maven依赖关系以及手动下载/拖放到/WEB-INF/lib文件夹中,因此我的war文件中现在有2个dark-hive.jar:
Because of Maven dependency and manual download/drop into /WEB-INF/lib folder I now have 2 dark-hive.jar in my war file:
- /WEB-INF/lib/dark-hive-1.0.8.jar
- /WEB-INF/lib/dark-hive.jar
两者的内部结构相同.
我正在使用WildFly 8.1.0.Final和升级的JSF Mojarra 2.2.8,PrimeFaces 5.1,OmniFaces 1.8.1
I am using WildFly 8.1.0.Final with upgraded JSF Mojarra 2.2.8, PrimeFaces 5.1, OmniFaces 1.8.1
有什么想法吗?
推荐答案
答案在于使用OmniFaces展示柜HeadRenderer.
The answer lies within the use of OmniFaces showcase HeadRenderer.
在我的faces-config.xml中,我正在使用:
In my faces-config.xml I was using:
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>org.omnifaces.showcase.HeadRenderer</renderer-class>
</renderer>
</render-kit>
使用了primefaces-aristo主题. 解决方案是根据以下条件编写我自己的HeadRenderer:
which used the primefaces-aristo theme. Solution was to write my own HeadRenderer according to:
这篇关于通过primefaces在Primefaces 5.1中应用主题.主题不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!