Java p:commandButton在p:dialog内不工作
我的xhtml页面有ui:repeat,我需要从中打开对话框,将消息发送给单击按钮的用户。为此,我尝试了以下两种方法: 1.)将p:对话框移动到单独的h:窗体中,如下所示:Java p:commandButton在p:dialog内不工作,java,jsf-2,primefaces,tomcat7,Java,Jsf 2,Primefaces,Tomcat7,我的xhtml页面有ui:repeat,我需要从中打开对话框,将消息发送给单击按钮的用户。为此,我尝试了以下两种方法: 1.)将p:对话框移动到单独的h:窗体中,如下所示: <p:dialog id="dialog" showHeader="true" header="Write your message" closable="true" widgetVar="dlg" resizable="false" draggable="true" modal="true" styleClass="
<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>
<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>
我使用ui中的以下按钮调用此对话框:重复:
<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>
<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:对话框的形式与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始终具有来自数据列表第一行的参数值
请建议..尝试另一种方法(它对我有效)
其他信息:MyBean是ViewScope我的方法声明类似于:public void myMethod(ActionEvent事件){}感谢@jimha的响应,我已经尝试过这个(p:h:form内的对话框),但它也不起作用。奇怪的是,这种方法对我很有效,而且现在它在生产服务器上使用我的其他代码,但现在在本地服务器上它自动停止工作。你需要添加我发布的代码,超出了原则你在这样做吗?(因为嵌套表单会产生一些问题)是的,我没有嵌套表单。两个h:form在页面上都是单独的表单。正如我之前所说,我也尝试过你的代码,但没有成功:(.无论如何,谢谢.)。。