【发布时间】:2012-11-07 07:13:38
【问题描述】:
我有一个模板组合Button.xhtml,其中包含一个<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。
我有一个模板客户端defaultPage.xhtml,其中包含Button.xhtml。
<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>中。
<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 时,<p:commandLink> 中的<p:commandLink> 停止工作,但页面的 CSS 工作正常。当我删除 <h:head></h:head> 或将其替换为 <head></head> 时,<p:commandLink> 开始工作,但 CSS 停止工作。
这是怎么引起的,我该如何解决?
【问题讨论】:
-
您在使用 ICEfaces 吗?或者您是否在没有实际测试的情况下粗心地过度简化了代码 sn-ps(即您最初使用例如 PrimeFaces
<p:commandLink>但由于某些不清楚的原因您将其过度概括为<h:commandLink>)?否则,阿米尔的回答毫无意义。在<h:commandLink>上默认没有 ajax bahvaiour。 -
是的,我使用了
这就是它开始起作用的原因。我错误地忘记提及了 -
-1 因为在提出问题时粗心,导致问题根本没有显示 任何 问题。一旦你解决了这个问题,我就会删除反对票。 aamir 的回答可能暗示了解决方案,但考虑到您实际上使用的是 PrimeFaces,这在技术上也是错误的。在以后的问题中,将代码 sn-ps 自己测试到一个空白的游乐场环境中;最简单的做法是您自己就是回答者,并尝试根据问题中提供的信息重现问题。
标签: jsf primefaces