【问题标题】:Richfaces <a4j:ajax> and <rich:popupPanel> "conflict"Richfaces <a4j:ajax> 和 <rich:popupPanel> “冲突”
【发布时间】:2012-10-01 06:09:35
【问题描述】:

我偶然发现了富人的一种奇怪行为。关于我的视图结构的一些背景:

  • 主要是&lt;rich:extendedDataTable&gt;,点击一行会在&lt;a4j:outputPanel&gt;上显示有关它的信息

  • 此外,每一行都有一个上下文菜单,其中包含“创建”、“编辑”等项目...弹出&lt;rich:popupPanel&gt;

组件结构是这样的:

<h:panelGrid columns="2">
    <h:column>
        <rich:dataScroller for="testTable" maxPages="7"/>
        <rich:extendedDataTable id="testTable" value="#{testController.items}" rendered="#{testController.items.rowCount != 0}"
        selection="#{testController.selectedRow}" noDataLabel="No results to show" var="test" rows="20"
        style="width: 790px" selectionMode="single">

            <a4j:ajax execute="@form"
                event="selectionchange" 
                listener="#{testController.selectionListener}"
                render=":res"/>

            {columns to display}

        </rich:extendedDataTable>
    </h:column>

    <a4j:outputPanel id="res">
        <rich:panel header="Selected Rows:" rendered="#{not empty testController.selectedRows}">
            <rich:list type="unordered" value="#{testController.selectedRows}" var="t">
                <h:outputText value="#{t.name}"/>
                <br/>
                <h:outputText value="#{t.details}" converter="#{testConverter}"/>
            </rich:list>
        </rich:panel>
    </a4j:outputPanel>
</h:panelGrid>

<rich:contextMenu target="testTable" mode="ajax" id="contextMenu">
    <rich:menuItem label="Edit" render="popupEdit" oncomplete="#{rich:component('popupEdit')}.show();" mode="ajax"/>
</rich:contextMenu>

<rich:popupPanel id="popupEdit" modal="true" autosized="true" resizeable="false" moveable="false" domElementAttachment="form">
    <rich:hotKey key="esc" onkeyup="#{rich:component('popupEdit')}.hide(); return false;"/>
    <f:facet name="header">
        <h:outputText value="Edit Test"/>
    </f:facet>
    <f:facet name="controls">
        <h:outputLink value="#" onclick="#{rich:component('popupEditar')}.hide(); return false;">
            <h:graphicImage value="/resources/css/images/fechar_janela.png" width="20" height="20"/>
        </h:outputLink>
    </f:facet>

    <h:panelGrid id="popupEditContent" columns="2">
        ... {display of info}

            <a4j:commandButton value="Salvar" actionListener="#{testeController.update()}" render="tabelaTestes, contextMenu"/>
            <h:panelGroup id="messagePanel" layout="block">
                <rich:messages ajaxRendered="true" />
            </h:panelGroup>
    </h:panelGrid>
</rich:popupPanel>

现在奇怪的行为(使用 NetBeans):

  • 从 NetBeans 部署应用程序;
  • 在浏览器 (Firefox) 上打开已部署项目的 URL。表中内联的&lt;a4j:ajax&gt; 不起作用,我知道这是因为未调用“testController.selectionListener”并且未显示详细信息(它在支持bean 中设置属性current)。 contextMenu 有效,但 popupPanel 在所有字段中显示 null 或空属性(未设置 current 属性);
  • 返回IDE,删除所有&lt;rich:popupPanel&gt;部分并保存文件;
  • 返回浏览器,按 F5 并单击一行。现在&lt;a4j:ajax&gt; 工作并调用testController.selectionListener,在&lt;a4j:outputPanel&gt; 中显示详细信息。上下文菜单有效,但(显然)面板没有弹出;
  • 在IDE中,放回&lt;rich:popupPanel&gt;部分并保存文件;
  • 现在再次刷新页面,一切正常,显示详细信息,编辑弹出窗口显示所选行的正确信息。

我尝试在没有&lt;rich:popupPanel&gt; 部分的情况下部署它,并且调用了selecionListener。我认为问题在于使用&lt;a4j:ajax&gt;&lt;rich:popupPanel&gt; 部分部署页面,因此出现“冲突”。

  1. 我从 Richfaces 展示中获取了结构并进行了更改。我注意到在展示中,&lt;rich:popupPanel&gt; 被放置在 &lt;h:form&gt; 标记之外,在我的项目中被放置在 template.xhtml 中(因此顶部菜单页面有效)。错误可能是由这个展示位置引起的吗?

  2. 这是否被认为是要在 Richfaces 项目中提交的错误,还是我在那里遗漏了什么?

  3. 有解决办法吗?

非常感谢!

【问题讨论】:

    标签: ajax jsf netbeans richfaces popuppanel


    【解决方案1】:

    认为我已经解决了。我在 template.xhtml 中的&lt;h:form&gt; 标记中将id 属性设置为“form”,所以现在它看起来像这样:

    <h:body>
        <h:form id="form">
            <div id="top" class="top">
                <ui:insert name="top">Top</ui:insert>
            </div>
            <div id="content" class="center_content">
               <ui:insert name="content">Content</ui:insert>
            </div>
        </h:form>
    </h:body>
    

    这是我所做的唯一更改,现在所有组件在第一次部署后都能正常工作。

    编辑:在搜索另一个问题时找到了解决方案:JSF action call on secon click

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-19
      • 2012-02-25
      • 1970-01-01
      • 2012-02-11
      • 2013-12-07
      • 2014-12-26
      • 2011-10-17
      • 2012-02-03
      相关资源
      最近更新 更多