我有一个模板 xhtml :
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view />
<h:head>
</h:head>
<h:body>
<f:facet name="last">
<h:outputStylesheet name="/ressources/css/default.css" />
</f:facet>
<!-- Bandeau -->
<p:layout fullPage="true">
<p:layoutUnit position="north" style="height: 50px;">
<h:form id="menuForm">
<div id="bandeau">
<div id="menu" class="bandeauElement">
<p:commandLink action="#{myBean.allerVersPremierePage}">
<i class="fa fa-arrow-left" style="color: white" />
<f:ajax render="content cssContent contentForm" />
</p:commandLink>
</div>
</div>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form id="contentForm">
<ui:insert name="content">
<ui:include src="#{facePainter.mainContent}" />
</ui:insert>
</h:form>
<ui:insert name="cssContent">
<h:outputStylesheet library="css" name="#{facePainter.cssContent}" />
</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
我有一个 FacePainter:
@ManagedBean(name="facePainter")
@SessionScoped
public class FacePainter {
private String mainContent = "ressources/fragments/premierePage.xhtml";
private String cssContent = "ressources/css/default.css";
//getters/setters
}
我有一个 AccueilBean.java :
public void allerVersDeuxiemePage() {
facePainter.setMainContent("ressources/fragments/deuxiemePage.xhtml");
facePainter.setCssContent("ressources/css/deuxiemePage.css");
}
当我点击我的 commandLink 时,第二页正在加载。但是如果我检查我的 CSS,我没有“ressources/css/deuxiemePage.css”但是 href=RES_NOT_FOUND
你知道为什么吗 ?谢谢
编辑 :
我的模板
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view />
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="mobile-web-app-capable" content="yes" />
</f:facet>
<h:outputScript name="/ressources/js/primeFacesLocales.js" />
<title>
<ui:insert name="pageTitle">
TEST
</ui:insert>
</title>
<link rel="manifest" href="manifest.json" />
<ui:insert name="dynamicalCss" />
</h:head>
<h:body>
<h:form id="contentForm">
<p:growl id="growl" showDetail="true" autoUpdate="true"
globalOnly="true" />
<ui:insert name="dynamicalContent">
<ui:include src="#{facePainter.mainContent}" />
</ui:insert>
</h:form>
</h:body>
</h:html>
我的用户界面:作文:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" >
<h:head></h:head>
<h:body>
<ui:composition>
<f:facet name="last">
<h:outputStylesheet name="/ressources/css/default.css" />
<h:outputStylesheet name="/ressources/css/page1.css" />
</f:facet>
<p>Thanks you for the information.</p>
<h:commandLink value="Aller vers page2" action="#{myBean.allerVersPage2}" id="btnPage2">
<f:ajax render="dynamicalContent dynamicalCss contentForm" />
</h:commandLink>
</ui:composition>
</h:body>
</h:html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" >
<h:head></h:head>
<h:body>
<ui:composition>
<f:facet name="last">
<h:outputStylesheet name="/ressources/css/default.css" />
<h:outputStylesheet name="/ressources/css/page2.css" />
</f:facet>
<p>Thanks you for the information.</p>
<h:commandLink value="Aller vers page1" action="#{myBean.allerVersPage1}" id="btnPage1">
<f:ajax render="dynamicalContent dynamicalCss contentForm" />
</h:commandLink>
</ui:composition>
</h:body>
</h:html>
正文已正确更新,但我不明白为什么我需要按 F5 才能更新 CSS。你有什么想法吗:)?我认为这是我制作 CSS 之前的最后一个问题 :'(