繁体   English   中英

RichFaces的 <a4j:ajax> 和 <rich:popupPanel> “冲突”

[英]Richfaces <a4j:ajax> and <rich:popupPanel> “conflict”

我偶然发现了一张富人的面孔。 关于我的视图结构的一些背景:

  • 它主要是一个<rich:extendedDataTable> ,其中单击某行会在<a4j:outputPanel>上显示有关它的信息

  • 此外,每一行都有一个上下文菜单,其中包含诸如“创建”,“编辑”等之类的项目,并弹出一个<rich:popupPanel>

组件结构是这样的:

<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。 内联在表中的<a4j:ajax>不起作用,我知道这是因为未调用'testController.selectionListener'并且不显示详细信息(它将属性设置为后备bean中的current属性)。 contextMenu有效,但是popupPanel在所有字段中显示null或空属性(未设置current属性);
  • 返回IDE,删除所有<rich:popupPanel>部分并保存文件;
  • 返回浏览器,点击F5并单击一行。 现在, <a4j:ajax>起作用并调用testController.selectionListener ,在<a4j:outputPanel>显示详细信息。 上下文菜单可以工作,但是(显然)面板不会弹出;
  • 在IDE中,放回<rich:popupPanel>部分并保存文件。
  • 现在再次刷新页面,一切正常,显示详细信息,“编辑”弹出窗口显示所选行的正确信息。

我尝试在没有<rich:popupPanel>部分的情况下部署它,并且调用selecionListener。 我认为问题在于部署同时包含<a4j:ajax><rich:popupPanel>部分的页面,因此出现了“冲突”。

  1. 我从richfaces展示柜中获取了结构并进行了更改。 我注意到在展示柜中, <rich:popupPanel>放置在<h:form>标记之外,而在我的项目中则放置在template.xhtml中(因此,顶层菜单页面有效)。 错误是否可能是由此放置引起的?

  2. 可以认为这是要在richfaces项目中提交的错误,还是我在那丢失了一些东西?

  3. 有解决方法或解决方案吗?

非常感谢你!

我已经解决了。 我在template.xhtml的<h:form>标记中将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>

这是我所做的唯一更改,现在所有组件都在首次部署后开始工作。

编辑:搜索另一个问题时找到了解决方案: 在secon上单击JSF操作调用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM