1 Reply Latest reply on Aug 18, 2009 6:10 PM by nbelaevski

    Cancel button/ modalPanel

    timgozag

      Hi, I have been struggling with this issue for a few days and wonder if someone could help!

      Story: I m using richfaces (3.2.2) with a modal panel. In the modal panel, I have a Submit and a Cancel button. When users click on submit with incorrect input data, we show invalid messages in the modal. But then users want to click on Cancel button to close the modal. Next time when they click on the link to open the modal again, all the data from the old modal is still there even though I reRender the modal's form.
      --> I want when user open the modal, a brand new/ fresh modal appears with all default value.

      Code:

      Link to the modal:

       <h:graphicImage id="emailBtn"
       value="resource:///com/image/icons/email-icon.gif"
       onclick="Richfaces.showModalPanel('myModal');">
       <a4j:support event="onmousedown" reRender="myModalForm"/>
       </h:graphicImage>
      


      Cancel button:
       <a4j:commandButton
       type="Reset"
       immediate="true"
       value="Cancel"
       actionListener="#{backingBean.cancel}"
       ignoreDupResponses="true"
       requestDelay="100"
       oncomplete="Richfaces.hideModalPanel('myModal');"/>
      

      Backing Bean:
      ...
       public void cancel(@SuppressWarnings("unused") ActionEvent ae) {
       // Set all values to null
       this.value1 = null;
       ....
      
       // Then clear message
       FacesContext context = FacesContext.getCurrentInstance();
       FacesMessages.instance().clear();
       }
      


      Thank you!