无法理解< h:head>行为

无法理解< h:head>行为

问题描述:

我有一个模板组成Button.xhtml,其中包含<p:commandLink>:

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.

我有一个包含Button.xhtml的模板客户端defaultPage.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模板定义插入<h:form>内.

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>

当我将<h:head></h:head>放在Template.xhtml中时,然后Button.xhtml中的<p:commandLink>停止工作,但是页面的CSS可以正常工作.当我删除<h:head></h:head>或将其替换为<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>