doesn't the form do this automatically? if validation fails, i think the standard behavior is to return the user to the page just as they left it -- preferably with the appropriate error message....i know there are multiple ways to do the validation (and i'm not using the best way), but one way is to have a method like the one below in you form bean. If any of the following conditions are met, the user is returned to the page with the form populated.

Hope this helps.
-nathan

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (this.isBlankString(oldpassword)) {
errors.add("oldpassword",new ActionError("error.required.oldpassword"));
}


if (this.isBlankString(newpassword1)) {
errors.add("newpassword1", new ActionError("error.required.newpassword1"));
}


if (this.isBlankString(newpassword2)) {
errors.add("newpassword2", new ActionError("error.required.newpassword2"));
}


// Test to see if the new passwords are the same.
if (!newpassword1.equals(newpassword2)) {
errors.add("newpassword1", new ActionError("error.passwordmatch"));
}



return errors; }


On Thursday, June 5, 2003, at 09:59 AM, Sashi Ravipati wrote:


Hi

I am a newbie to struts...

I have a dynamic table which has a <html:text > and a <html:select> . The user cliks on a add button and enter values in each row of the table and submits the form.

How can I repopulate the valuse if validation fails.

Can some body give a working exapmle of the Action Form that is required for this kind of requirement.

I found this in Ted Husted site but had no clue as what he is trying to do, What is RESULT etc
— ----------------------------------------------------------------------- -------------------
<TABLE><html:form action="/item/StoreCategory">
<logic:iterate name="RESULT" property="iterator" id="row">
<TR>
<TH>name</TH>
<TH>category</TH>
</TR>
<TR>
<TD><bean:write name="row" property="name"/></TD>
<TD><%-- REMEMBER TO SPECIFY THE ITERATE ID AS THE NAME --%>
<html:select name="row" property="category">
<html:option value="ART">Art</html:option>
<html:option value="AUT">Automotive</html:option>
<%-- ... --%>
</html:select>
<%-- REMEMBER TO SPECIFY THE ITERATE ID AS THE NAME --%>
<html:hidden name="row" property="key"/>
</TD>
</TR>
</logic:iterate>
<TR>
<TD colspan="2" align="right">
<html:submit/>
</TD>
</TR>
</html:form>
</TABLE>
— ----------------------------------------------------------------------- -----------------





============================= Nathan Pitts Programmer Analyst Texas Animal Health Commission =============================


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to