Primefaces p:日历不能在ui下工作:组合

时间:2014-10-30 12:46:42

标签: jsf primefaces calendar composite-component

我在我的项目中使用了primefaces,除了p:primefaces的日历组件之外,一切正常。以下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,如下面的代码段所示,它可以正常工作。

<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?

1 个答案:

答案 0 :(得分:0)

我认为如果您使用此模板,它可能会对您有所帮助

<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>

遵循这个结构。