我使用 PrimeFaces 作为主要的 JSF 组件库。但我只需要在一个网页上使用它。其他网页不使用 PrimeFaces 库。我正在使用模板,这是模板的重要部分:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<f:facet name="first">
<title>
<ui:insert name="titleOfPage">Insert title</ui:insert>
</title>
</f:facet>
<h:outputStylesheet name="basic.css" library="css" />
<h:outputStylesheet name="template.css" library="css" />
<f:facet name="last">
<ui:insert name="scriptOfPage" />
<h:outputScript name="mainScript.js" library="javascript" />
<ui:insert name="styleOfPage" />
</f:facet>
</h:head>
<h:body>
我发现定义了 h:head 后,它会自动加载 PrimeFaces theme.css。加载页面的源代码部分如下所示:
<link href="/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo" rel="stylesheet" type="text/css">
我没有在模板或页面中使用任何实现模板的primefaces。但 h:head 仍然加载 theme.cs。是否可以仅在需要时加载此主题?
最佳答案
您可以阻止在 web.xml 中加载主题:
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>none</param-value>
</context-param>
在您想要主题的网站上,只需添加 css:
<link href="/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo" rel="stylesheet" type="text/css"/>
关于primefaces - 如何防止在 h :head 中加载 PrimeFaces theme.css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12331141/