5 Replies Latest reply on Mar 28, 2008 8:45 AM by Benno Markiewicz

    Reset modalPanel

    panky_p Novice

      I have problem with modalpanel as I click on NEW button it displays old values in modalPanel. I want to get refresh modalPanel after submit it shoud clear modalPanel values.
      Is there any help!!

      Thanks in anticipation!!

        • 1. Re: Reset modalPanel
          Mikael Andersson Master

          It is not really clear what you are doing, posting code might help us help you :)

          If the modal panel gets the new "cleared" values from a backing bean, make sure that you reRender the modal panel correctly (not the modal panel itself, but its content).
          This might help:

          • 2. Re: Reset modalPanel
            panky_p Novice

            Hi micke,
            my modalPanel code is

            <rich:modalPanel id="newPanel" minHeight="200" minWidth="500" resizeable="false"
             height="200" width="550" zindex="2000">
             <f:facet name="header"><h:outputText value="New Page" /></f:facet>
             <f:facet name="controls">
             <h:graphicImage value="close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('newPanel')" />
             <h:form id="newForm">
             <h:outputLabel>Car Type </h:outputLabel>
             <td><h:inputText id="carTitle" value="#{myCarBean.carTitle}"/></td>
             <h:outputLabel>Car Make </h:outputLabel>
             <td><h:inputText id="carMake" value="#{myCarBean.carMake}"/></td>
             <table border="0" cellpadding="5" cellspacing="0" width="300" align="center">
             <td align="center">
             <h:commandButton type="submit" value=" Save " action="#{myCar.newCar()}"/>
             <h:commandButton type="button" value="Cancel" action="javascript:Richfaces.hideModalPanel('newPanel');return false;" />
            and for button
            <a4j:commandButton value="Add New Car"
            oncomplete="javascript:Richfaces.showModalPanel('newPanel',{width:520, top:'10px', left:'75px'});return false;"/>

            when first time I click on Add New Car button it show modalPanel where i input values and save but when I click again on Add New Car button it shows modalPanel with old input values , but I want modalPanel should not contain previous input values!!


            • 3. Re: Reset modalPanel
              Pankaj Ghosh Newbie

              You must not be emptying the 'myCarBean' after first processing.
              If that doesnt work(i dont know your complete logic), Do above step and also, put the contents of modal panel in a a4j:outputPanel and reRender it after first processing.

              • 4. Re: Reset modalPanel
                panky_p Novice

                Hi Pankaj,
                I did try to empty my bean but it affects other processing,
                I also tried to empty only the fields which appear in modalPanel but no success,
                put the contents of modal panel in a a4j:outputPanel is ok but after first processing how can I reRender it ? unless and until Add New Car button is not pressed?
                I'm sorry but not much familiar with these things as I am beginner,

                If you can explain where should I use reRender that will be great for me!!


                Pankaj P Dev

                • 5. Re: Reset modalPanel
                  Benno Markiewicz Newbie

                  Trigger a refresh using the onHide-JS-function of the modalPanel. (The onShow-function is broken in 3.1.4 GA).

                  The property XXX of the Bean shall be set to a default value when calling Bean.setShallReInit().

                  Disadvantage: an additional Ajax-Request&Response

                   <a4j:form id="#{formId}">
                   <a4j:jsFunction name="resetOnHide" reRender="#{formId}" >
                   <h:outputText value="#{Bean.XXX}"/>