【发布时间】:2013-06-28 20:51:30
【问题描述】:
我的 xhtml 页面有 ui:repeat,我需要从中打开对话框,该对话框会将消息发送给单击按钮的用户。为此,我尝试了以下两种方法:
1.) 将 p:dialog 移动到单独的 h:form 中,如下所示:
<p:dialog id="dialog" showHeader="true" header="Write your message" closable="true" widgetVar="dlg" resizable="false" draggable="true" modal="true" styleClass="job_model_popup" height="300">
<h:form id="dialogForm">
<p:panel id="messageFormPanel">
<br />
<h:inputTextarea label="Message" styleClass="input_text_field" value="#{MyBean.messageBody}" rows="10" required="true" />
<br />
<br />
<p:commandButton actionListener="#{MyBean.myMethod}" value="Send" styleClass="btn" update=":parentForm:growl" oncomplete="handleRequest(xhr, status, args);">
<f:param name="_param1" value="#{list['param1Id']}" />
<f:param name="_param2" value="#{list['param2Id']}" />
</p:commandButton>
</p:panel>
</h:form>
</p:dialog>
我正在使用 ui:repeat 中的以下按钮调用此对话框:
<h:form id="parentForm">
<ui:repeat id="dataList" var="list" varStatus="status" value="#{MyBean.dataList}">
<p:commandLink value="Send Msg" oncomplete="dlg.show();" update=":dialogForm">
<f:param value="#{list}" name="list" />
</p:commandLink >
</ui:repeat>
</h:form>
这种方法的问题是 p:commandButton 没有在对话框内触发。另外奇怪的是,这段代码在 2 天前就可以正常工作,并且没有任何更改,它会自动停止工作:)。
2.) p:dialog 与 ui:repeat 格式相同:-
<h:form id="parentForm">
<ui:repeat id="dataList" var="list" varStatus="status" value="#{MyBean.dataList}">
<p:commandLink value="Send Msg" oncomplete="dlg.show();" update=":parentForm:messageFormPanel">
<f:param value="#{list}" name="list" />
</p:commandLink >
</ui:repeat>
<p:dialog id="dialog" showHeader="true" header="Write your message" closable="true" widgetVar="dlg" resizable="false" draggable="true" modal="true" styleClass="job_model_popup" height="300">
<p:panel id="messageFormPanel">
<br />
<h:inputTextarea label="Message" styleClass="input_text_field" value="#{MyBean.messageBody}" rows="10" required="true" />
<br />
<br />
<p:commandButton actionListener="#{MyBean.myMethod}" value="Send" styleClass="btn" update=":parentForm:growl" oncomplete="handleRequest(xhr, status, args);">
<f:param name="_param1" value="#{list['param1Id']}" />
<f:param name="_param2" value="#{list['param2Id']}" />
</p:commandButton>
</p:panel>
</p:dialog>
</h:form>
这种方法的问题是 p:commandButton 现在正在工作,但它没有更新为单击 commandLink 按钮所在行的数据。因此 p:dialog 的 p:commandButton 始终具有 dataList 第一行的参数值。
请建议..
【问题讨论】:
-
附加信息:MyBean 是 ViewScoped 我的方法声明如下:public void myMethod(ActionEvent event) { }
标签: java jsf-2 primefaces tomcat7