[英]Richfaces <a4j:ajax> and <rich:popupPanel> “conflict”
I've stumbled upon a strage behavior of richfaces. 我偶然发现了一张富人的面孔。 Some background about my view structure: 关于我的视图结构的一些背景:
It's mainly a <rich:extendedDataTable>
where a click on a row displays info about it on a <a4j:outputPanel>
它主要是一个<rich:extendedDataTable>
,其中单击某行会在<a4j:outputPanel>
上显示有关它的信息
Also, each row has a context menu with items like "Create", "Edit", etc... that pops a <rich:popupPanel>
此外,每一行都有一个上下文菜单,其中包含诸如“创建”,“编辑”等之类的项目,并弹出一个<rich:popupPanel>
The component structure is this: 组件结构是这样的:
<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>
And now the strange behaviour (using NetBeans): 现在奇怪的行为(使用NetBeans):
<a4j:ajax>
inlined in the table doesn't work, I know this because the 'testController.selectionListener' is not called and the details are not displayed (it sets the attribute current
in the backing bean). 内联在表中的<a4j:ajax>
不起作用,我知道这是因为未调用'testController.selectionListener'并且不显示详细信息(它将属性设置为后备bean中的current
属性)。 The contextMenu works but the popupPanel shows null or empty properties in all fields (the current
attribute is not set); contextMenu有效,但是popupPanel在所有字段中显示null或空属性(未设置current
属性); <rich:popupPanel>
section and save the file; 返回IDE,删除所有<rich:popupPanel>
部分并保存文件; <a4j:ajax>
works and calls testController.selectionListener
, showing the details in <a4j:outputPanel>
. 现在, <a4j:ajax>
起作用并调用testController.selectionListener
,在<a4j:outputPanel>
显示详细信息。 The context menu works but (obviously) the panel does not pop; 上下文菜单可以工作,但是(显然)面板不会弹出; <rich:popupPanel>
section and save the file; 在IDE中,放回<rich:popupPanel>
部分并保存文件。 I have tried deploying it without the <rich:popupPanel>
section and the selecionListener gets called. 我尝试在没有<rich:popupPanel>
部分的情况下部署它,并且调用selecionListener。 I think that the problem is deploying the page with both <a4j:ajax>
and <rich:popupPanel>
sections, hence the "conflict". 我认为问题在于部署同时包含<a4j:ajax>
和<rich:popupPanel>
部分的页面,因此出现了“冲突”。
I took the structure from the richfaces showcase and made changes. 我从richfaces展示柜中获取了结构并进行了更改。 I noticed that in the showcase, the <rich:popupPanel>
is placed outside the <h:form>
tag, wich in my project is placed in the template.xhtml (so a topmenu page works). 我注意到在展示柜中, <rich:popupPanel>
放置在<h:form>
标记之外,而在我的项目中则放置在template.xhtml中(因此,顶层菜单页面有效)。 Is it possible that the error is caused by this placement? 错误是否可能是由此放置引起的?
Could this be considered a bug to file in the richfaces project or am I missing something there? 可以认为这是要在richfaces项目中提交的错误,还是我在那丢失了一些东西?
Is there a workaround or solution? 有解决方法或解决方案吗?
Thank you very much! 非常感谢你!
I think I have solved it. 我想我已经解决了。 I set the id
attribute to "form" in the <h:form>
tag, in template.xhtml, so now it looks like this: 我在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>
It was the only change I made and now all the components work at first post-deploy. 这是我所做的唯一更改,现在所有组件都在首次部署后开始工作。
Edit: Found the solution when searching for another problem: JSF action call on secon click 编辑:搜索另一个问题时找到了解决方案: 在secon上单击JSF操作调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.