primefaces - 如何防止在 h :head 中加载 PrimeFaces theme.css

标签 primefaces

我使用 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/

相关文章:

java - 如何让 subview 在每次渲染时创建一个新 View

jsf-2 - 如何处理javax.faces.resource资源未找到

javascript - 使用 JSF 和 Viewer.js 从文件系统打开 PDF 文件

javascript - 是 Primefaces p :editor safe to use?

jsf-2 - p :selectOneMenu list display

jsf - 应该在 p :tree to select a tree node and have a context menu? 上使用什么事件

jquery - 使用 JQuery 获取对 PrimeFaces widgetVar 的引用

javascript - 在 PrimeFaces 中更新某些组件时自动调用 javascript

java - 带 Primefaces 图表的 CDI 无法正确渲染

pdf - 默认 header p :media with pdf player