[英]p:commandButton not working inside p:dialog
我的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.)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第一行中的參數值。
請建議..
嘗試另一種方法(對我有用)
<h:form id="dialogForm">
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.