2 Replies Latest reply on Oct 8, 2009 9:24 AM by leelavathic leelavathic

    rich:modalpanel retaining previous value on validation error

    leelavathic leelavathic Novice

      Richfaces 3.3.1
      Tomcat 6.0.16

      I have a modal panel containing two mandatory fields - name and code.
      In the modal panel if the user enters only name field and submits the form, 'Code is mandatory' message is displayed. Now if the user closes the modal panel and again opens the modal panel. The last entered name field value is displayed.

      Expected result : The name and code fields should be empty.

      homePage.xhtml

      <a4j:form id="gameListForm" >
       <rich:panel id="gameList" >
       <rich:dataTable id="gameTable" var="game" value="#{gameMgdBean.gameList}" > ..................</rich:dataTable>
       </rich:panel>
       <a4j:commandButton value="Add Game" title="Add Game" action="#{gameMgdBean.initAdd}" oncomplete="Richfaces.showModalPanel('addModalPanel',{left:'auto', top:'auto',height:'200px',width:'400px'});" limitToList="true" reRender="addPanel" />
      <a4j:form />
      
      
      
      <a4j:outputPanel ajaxRendered="true">
       <rich:modalPanel id="addModalPanel" >
       <a4j:outputPanel id="addPanel" ajaxRendered="true">
       <a4j:include id="addGameModal" viewId="/home/gameeditor/addGame.xhtml"/>
       </a4j:outputPanel>
       </rich:modalPanel>
      </a4j:outputPanel>
      


      addGame.xhtml
      <a4j:form id="frmAddGame">
       <h:panelGrid >
       <h:outputText value="Display Name:" />
       <h:inputText id="displayName" label="Display Name" required="true" value="#{gameMgdBean.gameDTO.name}" />
       <h:outputText value="Code: " />
       <h:inputText id="code" value="#{gameMgdBean.gameDTO.code}" label="Code" required="true" />
       </h:panelGrid>
       <a4j:commandButton id="cmdAdd" value="Save" title="Save" action="#{gameMgdBean.addGame}" type="submit" limitToList="true" reRender="gameList" />
       <a4j:commandButton id="cmdCancel" value="Cancel" title="Cancel" immediate="true" onclick="Richfaces.hideModalPanel('addModalPanel');" reRender="gameList" limitToList="true" />
      </a4j:form>
      


      I could resolve the issue by defining a navigation rule for cancel button i.e,
      1. Added action="cancel" for cancel button

      <a4j:commandButton id="cmdCancel" value="Cancel" title="Cancel" action="cancel" immediate="true" onclick="Richfaces.hideModalPanel('addModalPanel');" reRender="gameList" limitToList="true"/>


      2. Added navigation rule

      <navigation-rule>
      <from-view-id>/home/gameeditor/addGame.xhtml</from-view-id>
      <navigation-case>
      <from-action>cancel</from-action>
      <to-view-id>/home/gameeditor/addGame.xhtml</to-view-id>
      </navigation-case>
      </navigation-rule>


      But is there any other solution other than the above ?