【发布时间】:2012-10-01 06:09:35
【问题描述】:
我偶然发现了富人的一种奇怪行为。关于我的视图结构的一些背景:
主要是
<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> 部分部署页面,因此出现“冲突”。
我从 Richfaces 展示中获取了结构并进行了更改。我注意到在展示中,
<rich:popupPanel>被放置在<h:form>标记之外,在我的项目中被放置在 template.xhtml 中(因此顶部菜单页面有效)。错误可能是由这个展示位置引起的吗?这是否被认为是要在 Richfaces 项目中提交的错误,还是我在那里遗漏了什么?
有解决办法吗?
非常感谢!
【问题讨论】:
标签: ajax jsf netbeans richfaces popuppanel