【问题标题】:Facelet component ui:composition not passing value to Managed beanFacelet 组件 ui:composition 未将值传递给托管 bean
【发布时间】:2015-03-29 03:34:42
【问题描述】:

我有一个包含四个部分(页眉、菜单、内容和页脚)的页面;我为此使用了ui:include。在内容部分,有一个inputText 和一个commandButton(提交)。当我按下提交按钮时,我输入的 inputText 值没有传递给 bean。我无法使用 null(输入文本值)执行我的功能。

索引页面:

<h:body >

    <p:poll interval="1" />
    <div
        style="background-color: #E6E6FA;border-width: 1px; border-color: blue; border-style: solid;">
        <ui:insert name="header">
            <ui:include src="header.xhtml" />
        </ui:insert>
    </div>
    <br />
    <div
        style="background-color: #E6E6FA; border-width: 1px; border-color: blue; border-style: solid;">
        <ui:insert name="menubar">
            <ui:include src="menubar.xhtml" />
        </ui:insert>
    </div>
    <br />
    <div
        style="background-color: #E6E6FA;border-width: 1px; border-color: blue; border-style: solid; border-width: 1px; min-height: 700px;">

        <ui:insert name="content" id="mainpage">

            <ui:include src="#{menuBarBean.menuBarDTO.page}.xhtml" ajax="true"/>
        </ui:insert>
    </div>
    <br />
    <div
        style="background-color: #E6E6FA;border-width: 1px; border-color: blue; border-style: solid;">
        <ui:insert name="footer">
            <ui:include src="footer.xhtml" />
        </ui:insert>
    </div>

 </h:body>
</html>

内容页面:

<body bgcolor="E6E6FA">
<ui:composition>            
        <h:panelGrid id="panel" columns="2" border="1" cellpadding="10"
            cellspacing="1">
            <f:facet name="header">
                <h:outputText value="Adding Project" />
            </f:facet>
            <h:outputLabel value="ProjectName" />
            <p:inputText id="emailId"
                value="#{addProjectBean.addProjectDTO.projectName}" required="true"
                validatorMessage="input needed">
            </p:inputText>
            <h:commandButton action="#{addProjectBean.addNewProject}"
                value="Submit" ajax="false" />
            <h:commandButton value="#{msg['prometheus_reset']}"
                style="margin-right:20px;">
                <p:ajax update="panel" resetValues="true" />
            </h:commandButton>
        </h:panelGrid>
        <h:outputLabel name="loginCheck"
            value="#{loginBean.loginDTO.message}" style="color:red">    
        </h:outputLabel>
     </ui:composition>
   </body>

【问题讨论】:

  • 我建议退后一步,先学习一些基本的 HTML,然后再深入 JSF。

标签: jsf-2 facelets uiinclude


【解决方案1】:

在 ui:composition 中使用 ajax="false" 代替 ajax="true"。

<ui:include src="#{menuBarBean.menuBarDTO.page}.xhtml" ajax="true"/>

更新

  <ui:include src="#{menuBarBean.menuBarDTO.page}.xhtml" ajax="false"/>

值正在传递给托管 bean,一切正常。

【讨论】:

    猜你喜欢
    • 2015-12-02
    • 1970-01-01
    • 2018-03-11
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 2016-07-07
    • 1970-01-01
    相关资源
    最近更新 更多