4 Replies Latest reply on Nov 30, 2007 11:09 AM by Stephane Moreau

    Modalpanel form cache

    Stephane Moreau Newbie

      We have a modalpanel which has a form in it. The form is not embedded in another form but exists on it's own. The data is submitted correctly when there is no validation error. Once a validation has been invoked and the error message is displayed the data in the form is cached. If the modal panel is closed (or hidden) with the incorrect data then the modalpanel is invoked again, the incorrect data reappears. The form in the modalpanel is rerendered which still does not resolve the problem.

        • 1. Re: Modalpanel form cache
          Ilya Shaikovsky Master

          show us your code please.

          • 2. Re: Modalpanel form cache
            Stephane Moreau Newbie

            Here is the code of the modal panel:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:c="http://java.sun.com/jstl/core"
             xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
             xmlns:rich="http://richfaces.ajax4jsf.org/rich">
            
             <rich:modalPanel id="editOrderModalPanel" height="340" width="500" zindex="2000" resizeable="false">
             <f:facet name="header">
             <h:panelGroup id="editOrderModalPanelTitle">
             <h:outputText value="Create Order" rendered="#{orderBean.order.unid == 0}" />
             <h:outputText value="Edit Order" rendered="#{orderBean.order.unid != 0}" />
             </h:panelGroup>
             </f:facet>
            
             <f:facet name="controls">
             <h:graphicImage value="/images/modal_close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('editOrderModalPanel')" />
             </f:facet>
            
             <a4j:form id="editOrderForm">
             <h:panelGrid
             styleClass="content"
             columns="3"
             columnClasses="columnLabel,columnContent,columnValidationError"
             border="0">
            
             <f:verbatim>Project:</f:verbatim>
             <h:outputText value="#{orderBean.project.code} - #{orderBean.project.name}" styleClass="displayText"/>
             <f:verbatim> </f:verbatim>
            
             <f:verbatim>Total Cost:</f:verbatim>
             <h:panelGroup>
             <h:inputText id="totalCost" value="#{orderBean.order.amountPaidIncVAT}" styleClass="textInput" size="10" required="true" validator="#{orderBean.validateCost}">
             <f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
             </h:inputText>
             <f:verbatim> (inc VAT)</f:verbatim>
             </h:panelGroup>
             <h:message styleClass="errormsg" for="totalCost"/>
            
             </h:panelGrid>
            
             <h:panelGrid
             styleClass="content"
             columnClasses="textCentre"
             border="0">
            
             <h:panelGroup>
             <a4j:commandButton type="submit" action="#{orderBean.updateOrderAction}" value="Update"
             oncomplete="if (!ajaxRequestContainsErrors()) {Richfaces.hideModalPanel('editOrderModalPanel');reRenderOrderList();} else {Richfaces.showModalPanel('editOrderModalPanel',{width:750});}"
             styleClass="buttonInput" onmouseover="buttonOver(this);" onmouseout="buttonOut(this);"
             reRender="editOrderForm">
             <f:param name="orderId" value="#{orderBean.order.unid}"/>
             <f:param name="helpdeskRef" value="#{orderBean.helpdeskRef}"/>
             <f:param name="supplierId" value="#{orderBean.supplierId}"/>
             </a4j:commandButton>
            
             <a4j:commandButton type="submit" action="#{orderBean.cancelAction}" value="Cancel" immediate="true"
             oncomplete="Richfaces.hideModalPanel('editOrderModalPanel');reRenderOrderList();"
             styleClass="buttonInput" onmouseover="buttonOver(this);" onmouseout="buttonOut(this);">
             <f:param name="orderId" value="#{orderBean.order.unid}"/>
             <f:param name="helpdeskRef" value="#{orderBean.helpdeskRef}"/>
             <f:param name="supplierId" value="#{orderBean.supplierId}"/>
             </a4j:commandButton>
             </h:panelGroup>
            
             </h:panelGrid>
             </a4j:form>
            
             </rich:modalPanel>
            
            </html>
            


            • 3. Re: Modalpanel form cache
              Jawher Moussa Newbie

              Hi

              You may try to put your form inside an <a4j:outputPanel ajaxRendered="true"> component.

              Regards.

              • 4. Re: Modalpanel form cache
                Stephane Moreau Newbie

                I found the solution!
                The solution is to clear the input components from the component tree.
                Here is the website I used, very helpful:
                http://wiki.apache.org/myfaces/ClearInputComponents