【问题标题】:Primefaces p:calendar not working under ui:compositionPrimefaces p:日历在ui:composition下不起作用
【发布时间】:2014-10-30 12:46:41
【问题描述】:

我在我的项目中使用了 primefaces,一切正常,除了 Primefaces 的 p:calendar 组件。以下 xhtml 文件不显示日历组件。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/Templates/Commons/MainContent.xhtml">
    <ui:define name="main_content"> 
        <h:body>
        <h:form>
            <p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
        </h:form>
        </h:body>
    </ui:define> 
</ui:composition>

但是,如果我删除 ui:compisition ,如下面的 sn-p 所示,它可以正常工作。

<html xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">
        <h:body>
        <h:form>
            <p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
        </h:form>
        </h:body>
</html>

关于 ui:compisition 和 p:calendar 有什么我应该知道的吗?

【问题讨论】:

  • 您是否检查过以第二种方式包含MainContent.xhtml 文件?
  • @QadirHussain 也不起作用。
  • 发布你的堆栈跟踪怎么样?
  • 你能发布你的 MainContent.xhtml 吗?你确定这个模板的路径是正确的吗?
  • @Multisync 模板中的所有内容都显示,包括除 p:calendar 组件之外的其他 Primefaces 组件。

标签: jsf primefaces calendar composite-component


【解决方案1】:

我认为如果你使用这个模板可能会对你有所帮助

<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:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/WEB-INF/Templates/Commons/MainContent.xhtml">
      <ui:define name="main_content">
         <h:body>
            <h:form>
                <p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
            </h:form>
        </h:body>
      </ui:define>
    </ui:composition>
</html>

遵循这个结构。

【讨论】:

  • ,知道除了 p:calendar 之外的所有其他 Primefaces 组件都可以正常工作。我按照你的建议进行了尝试,但无法使 p:calendar 工作。让我知道它是否适合你。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-03
  • 2022-12-31
  • 1970-01-01
  • 2012-09-19
  • 2014-10-15
  • 2013-12-05
  • 1970-01-01
相关资源
最近更新 更多