if you give the error mssage a different property then you can differentiate between the two
errors.add("javascriptErrors", new ActionError("error.js.field.missing", fieldName)); errors.add("textError", new ActionError("error.text.field.missing", fieldName)); <html:errors property="textError"/> this above html:errors tag will only display errors that have the "textError" property there no limit to the number of different error properties you can have. for example I have a form where you canenter user details in, if any required fields are missing it makes an error with property "top" errors.add("top", new ActionError("error.fields.missing")); this erro says something generic like "Some of the required fields are missing, see arrows below" in my page the <html:error property="top"/> tag goes at the top of the form. and next to each missing field I have a <html:errors proerty="myFieldName"/> if that field is missing I create an error like errors.add("myFieldName", new ActionError("error.left.arrow")); this then lets me use one text error, and then have an arrow point to each of the missing fields in the form. Regards Steve -----Original Message----- From: Vance Heredia [mailto:[EMAIL PROTECTED] Sent: Monday, 11 August 2003 2:08 PM To: 'Struts Users Mailing List' Subject: RE: How to return to form element Hmmmmms sounds nifty but how would I then display an error message as well???? The more I use JS the more I like it ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Vance Heredia ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > -----Original Message----- > From: Steve Vanspall [mailto:[EMAIL PROTECTED] > Sent: Monday, 11 August 2003 1:25 PM > To: Struts Users Mailing List > Subject: RE: How to return to form element > > > Well I dont know of any easy way to do it > > but you could probably make use of the action errors somehow. > > maybe create, in your message resurces file, a piece of > javascript that dynamically set the name of the field to be > focused on. Then the onload function would focus on it for > you. Sounds a bit complicated but would go something like this. > > -- if form validate -- > boolean firstField = true; > if(myField == null) > { > if(firstField) > { > errors.add("javascriptErrors", new > ActionError("error.js.field.missing", > fieldName)); > firstField = false; > } > > } > > -- in message resources -- > > error.js.field.missing = <script>focusField = {0}</script> > > -- in page -- > <script> > var focusFiled = null; > </script> > > <body onload="if(focusField != null) document.all[focusField].focus;"> > > <html:errors property="javascriptErrors"/> > > > > That's if you're making use of the message resources feature. > > Just one possible suggestion > > Steve > > > -----Original Message----- > From: Vance Heredia [mailto:[EMAIL PROTECTED] > Sent: Monday, 11 August 2003 1:04 PM > To: '[EMAIL PROTECTED]' > Subject: How to return to form element > > > > I use the Action Errors to validate a form. > > If I do find errors does anyone know how to set the focus to > the first eroneous field present on the form when it returns to it ??? > > Vance > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Vance Heredia > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ______________________________________________________________________ > This email, including attachments, is intended only for the > addressee and may be confidential, privileged and subject to > copyright. If you have received this email in error, please > advise the sender and delete it. If you are not the intended > recipient of this email, you must not use, copy or disclose > its content to anyone. You must not copy or communicate to > others content that is confidential or subject to copyright, > unless you have the consent of the content owner. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ______________________________________________________________________ This email, including attachments, is intended only for the addressee and may be confidential, privileged and subject to copyright. If you have received this email in error, please advise the sender and delete it. If you are not the intended recipient of this email, you must not use, copy or disclose its content to anyone. You must not copy or communicate to others content that is confidential or subject to copyright, unless you have the consent of the content owner. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]