Jsf 从test.xhtml更新template.xhtml上的组件

Jsf 从test.xhtml更新template.xhtml上的组件,jsf,primefaces,Jsf,Primefaces,我的模板上有一个菜单栏,我在每个页面上都使用它。我想从另一个基于模板的页面更新模板中的组件 它的工作原理和其他任何电子邮件页面一样,只要我读了一封电子邮件,它就会更新未读电子邮件的数量。号码显示在template.xhtml的菜单栏中,电子邮件显示在my test.xhtml上。一旦我读到一封电子邮件,它就会在template.xhtml中的菜单栏中更新未读电子邮件的数量 这是我的template.xhtml <ui:define name="navi"> <h:for

我的模板上有一个菜单栏,我在每个页面上都使用它。我想从另一个基于模板的页面更新模板中的组件

它的工作原理和其他任何电子邮件页面一样,只要我读了一封电子邮件,它就会更新未读电子邮件的数量。号码显示在template.xhtml的菜单栏中,电子邮件显示在my test.xhtml上。一旦我读到一封电子邮件,它就会在template.xhtml中的菜单栏中更新未读电子邮件的数量

这是我的template.xhtml

<ui:define name="navi">
    <h:form id="navForm">
        <div id="MMeineVersicherungen" class="hauptmenu">
            <h:commandLink action="#{navigationController.switchView('1')}">#{messages['menu.1']}</h:commandLink>
        </div>
        <div id="MPolizzen" class="menuitem">
            <h:commandLink action="#{navigationController.switchView('1.1')}"
                styleClass="#{navigationController.isAktPageId('1.1') or navigationController.isAktPageId('1') ? 'activelink' : ''}">- #{messages['menu.1.1']}</h:commandLink>
        </div>
        <div id="MSchaeden" class="menuitem">
            <h:commandLink action="#{navigationController.switchView('1.2')}"
                styleClass="#{navigationController.isAktPageId('1.2') ? 'activelink' : ''}">- #{messages['menu.1.2']}</h:commandLink>
        </div>
        <div id="MTopKunden" class="menuitem">
            <h:commandLink action="#{navigationController.switchView('1.3')}"
                styleClass="#{navigationController.isAktPageId('1.3') ? 'activelink' : ''}">- #{messages['menu.1.3']}</h:commandLink>
        </div>

        <div id="MMeineDaten" class="hauptmenu">
            <h:commandLink action="#{navigationController.switchView('2')}">#{messages['menu.2']}</h:commandLink>
        </div>
        <div id="MKundendaten" class="menuitem">
            <h:commandLink action="#{navigationController.switchView('2.1')}"
                styleClass="#{navigationController.isAktPageId('2.1') or navigationController.isAktPageId('2') ? 'activelink' : ''}">- #{messages['menu.2.1']}</h:commandLink>
        </div>
        <div id="MBenutzer" class="menuitem">
            <h:commandLink action="#{navigationController.switchView('2.2')}"
                styleClass="#{navigationController.isAktPageId('2.2') ? 'activelink' : ''}">- #{messages['menu.2.2']} </h:commandLink>
        </div>

        <div id="MPostfach" class="hauptmenu">
            <h:commandLink action="#{navigationController.switchView('3')}"
                styleClass="#{navigationController.isAktPageId('3') ? 'activelink' : ''}">(#{post.getAnzahlNeueNachrichten()}) #{messages['menu.3']} </h:commandLink>
        </div>
        <div id="MKommunikationsvereinb" class="hauptmenu">
            <h:commandLink action="#{navigationController.switchView('4')}"
                styleClass="#{navigationController.isAktPageId('4') ? 'activelink' : ''}">#{messages['menu.4']}</h:commandLink>
        </div>

        <div id="MAbmelden" class="hauptmenu" style="margin-top: 20px;">
            <h:commandLink action="#{loginController.logout}"
                value="#{messages['menu.5']}" />
        </div>
    </h:form>
</ui:define>

#{messages['menu.1']}
-#{messages['menu.1.1']}
-#{messages['menu.1.2']}
-#{messages['menu.1.3']}
#{messages['menu.2']}
-#{messages['menu.2.1']}
-#{messages['menu.2.2']}
(#{post.getAnzahlNeueNachrichten()})#{messages['menu.3']}
#{messages['menu.4']}
这是test.xhtml

<ui:define name="main">
    <h:form id="postform">
        <p:dialog id="msgdlg" dynamic="true" modal="true" widgetVar="msgdlg"
            width="600" height="500">
            <f:facet name="header">#{post.aktNachricht.subject}</f:facet>
            <p:ajax event="close" listener="#{post.closeDlg}" />
            <p:hotkey bind="esc" handler="msgdlg.hide(); " />
            <ui:include src="#{post.view}" />
        </p:dialog>

        <p:tabView id="posttabview" activeIndex="0" cache="true">

            <p:tab id="empftab" title="#{messages['post.empfangen']}"
                titleStyleClass="thementab">
                <p:dataTable value="#{post.empfangenList}" var="msg">
                    <p:column styleClass="coldatum">
                        <p:commandLink action="#{post.showNachricht(msg)}"
                            oncomplete="msgdlg.show();" update=":postform">
                            <h:outputText value="#{msg.datum}"
                                styleClass="#{msg.gelesen ? '' : 'unread'}">
                                <f:convertDateTime pattern="dd.MM.yyyy"
                                    timeZone="Europe/Berlin" />
                            </h:outputText>
                        </p:commandLink>
                    </p:column>
                    <p:column>
                        <h:outputText value="#{msg.subject}"
                            styleClass="#{msg.gelesen ? '' : 'unread'}" />
                    </p:column>


                </p:dataTable>
            </p:tab>

            <p:tab id="sendtab" title="#{messages['post.gesendet']}"
                titleStyleClass="thementab">
            </p:tab>

        </p:tabView>

        <br />
        <p:commandButton value="#{messages['post.neu']}" action="#{post.neu}"
            update="msgdlg" oncomplete="msgdlg.show();" />


    </h:form>
</ui:define>

#{post.aktNachricht.subject}


我自己找到了解决方案。你能把你找到的解决方案作为你自己问题的答案吗?这将有助于将来可能有相同问题的访问者。如果您的页面是从其他页面派生的,在本例中是从我的模板派生的,则可以使用派生页面中的组件id。