【问题标题】:load a new xhtml page on the same existing page without loosing the another html components [duplicate]在同一个现有页面上加载新的 xhtml 页面,而不会丢失另一个 html 组件 [重复]
【发布时间】:2018-06-26 17:41:36
【问题描述】:

我有这种情况: - 日食火星 -Primefaces 6.2 -JSF 2.1 -ibm 门户框架 - 在 websphere 上运行

当我点击 primefaces menuitem 以打开一个新的 xhtml 时,我需要在同一个网页上打开这个新的 xhtml 而不会丢失所有其他 html 现有组件。我只需要刷新一下。

这是我的项目:

我的主页(xhtml):

<h:body>
        <div id="divMain" style="height:200px">
            <ui:insert name="cabecalho">
                <ui:include src="/_MF/jsf/MainMenu.xhtml"></ui:include>
            </ui:insert>

            <ui:insert name="conteudo">


            </ui:insert>        
        </div>       
    </h:body>

MainMenu.xhtml:

<h:form id="myFormMainMenu">
            <div id="mainMenu">

                <p:megaMenu orientation="#{megaMenuView.orientation}" style="margin-top:20px" autoDisplay="true">
                <p:submenu label="DI" icon="ui-icon-check">
                    <p:column>
                        <p:submenu label="OPTIONS">
                            <p:menuitem value="Listing" icon="ui-icon-document"
                                ajax="false" action="#{mainMenuMB.listar()}" />
                        </p:submenu>
                    </p:column>
                </p:submenu>
            </p:megaMenu>

            </div>
</h:form>

从 menuitem listar() 提出的另一种形式:

<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:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

 <ui:composition template="/_MF/jsf/MainPage.xhtml">
    <ui:define name="conteudo">
        <div id="divListar">
          <h1>User settings.....</h1>
        </div>
    </ui:define>
  </ui:composition>


</html>

【问题讨论】:

  • @Kukeltje 你发给我的这个主题适用于 commandLink 但不适用于
  • 当我点击 menuitem 时它会加载新的 xhtml 但它会清除所有现有的 html 组件
  • ajax="false"进行全面刷新...以正确的方式尝试使用 ajax
  • 感谢@Kukeltje。它适用于您发送给我的现有帖子并更新 menuitem 标签。并删除 ajax="false"

标签: ajax jsf primefaces portal


【解决方案1】:

这个问题的解决方案通过以下两个项目得到解决:下面的链接和 cmets:添加了 update="content" 并删除了标签 ajax="false"

通过此链接可以正常工作How to ajax-refresh dynamic include content by navigation menu? (JSF SPA) &lt;f:ajax render=":content"&gt; ...

这个:我添加了 update='content' 并删除了 ajax="false"

 <p:menuitem value="Listing" icon="ui-icon-document" 
                                action="#{mainMenuMB.setPage('Listar')}" update="content"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-17
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多