无法理解 <h:head>行为 [英] Unable to understand <h:head> behaviour
问题描述
我有一个模板组合 Button.xhtml
,其中包含一个
:
I have a template composition Button.xhtml
which contains a <p:commandLink>
:
<ui:composition
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:p="http://primefaces.org/ui">
<p:commandLink value="View" action="#{printClass.printPdf}"/>
</ui:composition>
链接的目的是生成 PDF.
The link's purpose is to generate PDF.
我有一个模板客户端 defaultPage.xhtml
,其中包含了 Button.xhtml
.
I have a template client defaultPage.xhtml
where the Button.xhtml
is been included.
<ui:composition template="../../WebPages/MasterPage/Template.xhtml">
<ui:define name="MainContent">
<ui:include src="../../WebPages/Facelets/Button.xhtml"/>
</ui:define>
</ui:composition>
最后一个是 Template.xhtml
,它在
中插入 MainContent
模板定义.
The last one is Template.xhtml
which inserts the MainContent
template definition inside a <h:form>
.
<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">
<h:body>
<h:form>
<ui:insert name="MainContent" />
</h:form>
</h:body>
</html>
当我将
放在 Template.xhtml
中时,Button.xhtml
中的/code> 停止工作,但页面的 CSS 工作正常.当我删除 <h:head></h:head>
或将其替换为 </head>
然后 <;p:commandLink>
开始工作,但 CSS 停止工作.
When I place <h:head></h:head>
in Template.xhtml
, then the <p:commandLink>
in Button.xhtml
stops working, but CSS of page works perfect. When I remove the <h:head></h:head>
or replace it by <head></head>
then the <p:commandLink>
starts working, but CSS stops working.
这是怎么引起的,我该如何解决?
How is this caused and how can I solve it?
推荐答案
在您放置
<h:commandLink value="View" action="#{printClass.printPdf}"/>
你需要禁用ajax.所以你的新代码应该是
You need to disable the ajax.So your new code should be like
<h:commandLink value="View" action="#{printClass.printPdf}">
<f:ajax disabled="true"></f:ajax>
</h:commandLink>
这篇关于无法理解 <h:head>行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!