开发者

JSF 2.0 Primefaces close a dialog in a composite component

I want to display a composite component inside a dialog. It works but then how do I close that dialog from the composite component.

<p:commandButton value="Display Data Value Assertion Dialog" onclick="dlg2.show();" type="button"/> 
<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="600" width="800">  
        <tcmt:DataValueAssertion managedBean="#{dataValueAssertionController}"/>
</p:dialog>

In my composite component:

        <h:commandButton val开发者_开发百科ue="Save Assertions">
            <f:ajax listener="#{datatypeAssertionController.saveDatatypeAssertion}"></f:ajax>
        </h:commandButton>

        <h:commandLink value="Close">
            <f:ajax listener="#{datatypeAssertionController.closeDatatypeAssertion}"></f:ajax>
        </h:commandLink> 

When clicking on Save, I want to be able to save the data and close the dialog. When clicking on Cancel, I just want to close the dialog without saving. Both saveDatatypeAssertion and closeDatatypeAssertion methods are placeholders. I need to find a way to get a reference for the dialog dlg2 and then call the hide() method on it.


If you are using JSF 2.0.You can do like this:

 <h:commandButton value="Save Assertions"  >
  <f:ajax event="click" onevent="dlg2.hide()" listener="#{datatypeAssertionController.saveDatatypeAssertion}" />
 </h:commandButton>

<h:commandLink value="Close" >
      <f:ajax event="click" onevent="dlg2.hide()"  listener="#{datatypeAssertionController.closeDatatypeAssertion}" />
</h:commandLink> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜