struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anjib Mulepati <anji...@hotmail.com>
Subject Form data lost [S 1.3.8]
Date Tue, 31 Jul 2012 16:09:07 GMT
Hi All,

I am using large form to input data. I have some validation code as well 
as I have condition where if something goes wrong in execution of action 
it will take the user back to the form.
My problem is when validation fail or form returned from action 
execution all my form data are lost. How can I have form retain its data 
even after fail?
I am using struts tag for form and session scope for form.

     <html:form styleId="createAgentForm" action="createAgent" 
focus="agentVersion">

         <label for="agentVersion" class="formLabel"><bean:message 
key="label.agentVersion" />*</label>
         <html:text property="agentVersion" size="10" 
styleId="agentVersion" tabindex="1" titleKey="title.agentVersion" 
value="" />
         <br />

        ........

         <html:submit styleClass="submitbutton" tabindex="11" 
value="Create Agent" title="Create Agent" />

     </html:form>


   <action path="/createAgent"
type="com.anjib.actions.agencyadmin.CreateAgentAction"
                 input="/showCreateAgent.do"
                 name="CreateAgentForm"
                 scope="session" >
             <forward name="createAgentForm" path="/showCreateAgent.do"/>
         </action>


<action path="/showCreateAgent"
type="com.anjib.actions.agencyadmin.ShowCreateAgentAction">
             <forward name="success" path="createAgentPage"/>
         </action>


public class CreateAgentForm extends org.apache.struts.action.ActionForm {
     ..............................

     public ActionErrors validate(ActionMapping mapping, 
HttpServletRequest request) {
         ActionErrors errors = new ActionErrors();
         if (getAgentName() == null || getAgentName().length() < 1) {
             errors.add("createAgent", new 
ActionMessage("error.agentName.required"));
         }
        .................................................
         return errors;
     }
}

Thanks,
Anjib

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message