如何阻止仅从单个页面加载PrimeFaces theme.css?
答案 0 :(得分:0)
向pom.xml添加依赖项:
<!-- PrimeFaces Framework -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.3</version>
</dependency>
<!-- PrimeFaces All Themes -->
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
</dependency>
将此配置添加到web.xml
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>#{themeBean.theme}</param-value>
</context-param>
您需要使用 @ApplicationScoped 创建渴望 bean来加载和管理您的配置:
@ManagedBean(name = "themeBean", eager = true)
@ApplicationScoped
public class ThemeBean {
private String theme = "none";
public void setTheme(String theme) {
this.theme = theme;
}
public String getTheme() {
return theme;
}
}
使用开始配置&#34;无&#34;在主题名称中,您将阻止创建theme.css文件,但如果您需要更改,只需将新值设置为&#34; bootstrap&#34;加载另一个主题。
您应该考虑创建自定义主题,而不是删除theme.css。