Search code examples
jsf-2faceletsuiinclude

Facelet component ui:composition not passing value to Managed bean


I have a page with four parts (header, menu, content and footer); I used ui:include for that. In the content part, there is an inputText and a commandButton (submit). When I press the submit button, the inputText value I entered is not passed to the bean. I am not able to perform my function with null (input text value).

Index page:

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

Content page:

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

Solution

  • Instead of ajax="true" use ajax="false" in ui:composition.

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

    Updated

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

    values are passing to managed bean and everything working fine.