如何在 Primefaces 3 中通过 Java 代码设置主题?
例如,我有主题 test
。如何在 Primefaces 中使用 Java 代码设置此主题?我不想使用上下文参数 primefaces.THEME
并且我不想使用
。
I have for example theme test
. How to set this theme using Java code in Primefaces ? I don't want to use context param primefaces.THEME
and i don't want to use <p:themeSwitcher>
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种方法是:将样式表包含到页面模板中:
其中 #{themesBean.theme} 变量引用您的主题名称。
PS在PF5中测试
类似问题的相同答案 https://stackoverflow.com/a/24092773/2993327
One more way to do this: include stylesheet to your pages template:
<h:body>
<h:outputStylesheet library="primefaces-#{themesBean.theme}" name="theme.css" />
</h:body>
Where #{themesBean.theme} variable reffers to name of your theme.
P.S. tested in PF5
Same answer on similar question https://stackoverflow.com/a/24092773/2993327
这就是您需要做的(未经测试,但应该告诉您它应该如何工作)
代码:
代码:
代码:
您可以在以下 URL 上找到此解决方案 如何设置 PrimeFaces 主题?
This is what you need to do (untested, but should give you an indication how it should work)
Code:
Code:
Code:
You can find this solution on the following URL how to set a PrimeFaces theme?