Modal Panel Holding the Previously Entered Values
ambrish_kumar May 29, 2009 8:02 AMHi Everyone,
I am opening a modal panel by pressing a button.
Here is the code for opening a modal panel.
<h:form id="showAddform"> <h:panelGrid columns="1" columnClasses="name" styleClass="panelGrid"> <a:commandButton id="addUserButton" value="#{messages.btnNewUser}" reRender="commonPanel" action="#{userAction.renderAddUser}" /> </h:panelGrid> </h:form>
and my modal panel is here,
<a:outputPanel id="commonPanel"> <rich:modalPanel id="commonMp" styleClass="modalPanel" top="10" keepVisualState="#{userAction.showOverlay}" autosized="true" minWidth="600" minHeight="100" style="background-image: url('../img/overlayBg.png');background-repeat: repeat;background-color: transparent;" shadowDepth="#{messages.valShadowDepth}" headerClass="modalPanel-header" controlsClass="modalPanel-controls"> <f:facet name="header"> <h:outputText value="#{userAction.modelPanelHead}" /> </f:facet> <f:facet name="controls"> <h:graphicImage value="/img/closeButton.png" alt="X" border="0" style="cursor: pointer; cursor: hand;" onclick="Richfaces.hideModalPanel('commonMp')" > <a:support event="onclick" action="#{userAction.closeLayer}" ajaxSingle="true" disableDefault="true" eventsQueue="closeLayerUserQueue" /> </h:graphicImage> </f:facet> <h:panelGrid styleClass="modalPanel-panelGrid"> <h:message styleClass="message" for="commonPanel" style="color:red;"/> <h:form> <h:panelGrid columns="1" columnClasses="name" rendered="#{userAction.formToLoad=='addUserForm'}" styleClass="panelGrid"> <s:div styleClass="modalPanel-panelGrid-container-div"> <h:panelGrid columns="1" border="0" columnClasses="formLabel,formValue" rowClasses="formLabel"> <s:decorate id="userTypeDecoration" template="../layout/edit.xhtml"> <ui:define name="label">#{messages.lblUserType}</ui:define> <h:selectOneMenu value="#{userBean.userType}" required="true" requiredMessage="Value is required"> <s:selectItems value="#{userAction.userTypes}" var="cs" label="#{cs.strUserType}" noSelectionLabel="#{messages.defaultListItem}" /> <s:convertEntity /> </h:selectOneMenu> </s:decorate> </h:panelGrid> <h:panelGrid columns="2" border="0" columnClasses="formLabel,formValue" rowClasses="formLabel"> <s:decorate id="nameDecoration" template="../layout/edit.xhtml"> <ui:define name="label">#{messages.lblUserName}</ui:define> <h:inputText id="name" value="#{userBean.strUserName}" required="true" requiredMessage="Value is required"/> </s:decorate> </h:panelGrid> <h:panelGrid columns="1" border="0" width="100%" columnClasses="formLabel,formValue" rowClasses="formLabel"> <s:decorate id="descDecoration" template="../layout/edit.xhtml"> <ui:define name="label">#{messages.lblDescription}</ui:define> <h:inputTextarea id="desc" rows="8" cols="65" value="#{userBean.strDescription}" /> </s:decorate> </h:panelGrid> <h:panelGrid width="330" id="save"> <a:commandButton id="saveUserButton" value="#{messages.btnSave}" reRender="commonPanel" action="#{userAction.persistUserDetails}" rendered="#{userBean.iuserId == null}" /> </h:panelGrid> </s:div> </h:panelGrid> </h:form> </h:panelGrid> </rich:modalPanel> </a:outputPanel>
Now the problem is that, suppose I leave few required fields as empty, then validation messages are displaying with color of labels are RED. After that I closed the modal Panel by clicking on X.
Now , next time when I am opening the Modal Panel then it displays the previously filled value and some field labels (mandatory fields) as RED.
Is there any way so that the Modal panel doesn't hold the previously entered values.
Thanks
Ambrish