You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robin Mannering <Ro...@promap.co.uk> on 2004/10/05 14:09:19 UTC

ActionError and JSP display

Hi,

Platorm is : Tomcat 5, Struts 1.1
Context: HTML Form submissions and validation.

I'm trying to conditionally test for the existince of error messages by their keys.  And I'd then like to show the error with HTML formatting around it.

Basically, using tags, I'd like to do the same as the following following pseudo code.

if (errorMessage named 'usernameError' exists) {
	showError('usernameError' + some html)
}

The error message is set from within the Form class as:

    errors.add("usernameError", new ActionError("errors.form.username.required"));

I've been trawling around and have found lots of references to <logic:messagesPresent> and then looping through each message using <html:messages> but not a test for the existence of a particular message.

I'm trying to display the error message next to each appropriate form element rather than in a list.  I probably can't see the solution for looking.  Can anyone help?

Many thanks
Robin

====================================================================
This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this e-mail and you are not a named
addressee, please inform Landmark Information Group on 01491 413030
and then delete the e-mail from your system. If you are not a named
addressee you must not use, disclose, distribute, copy, print or rely 
on this e-mail. This email and any attachments have been scanned for
viruses and to the best of our knowledge are clean. To ensure 
regulatory compliance and for the protection of our clients and 
business, we may monitor and read e-mails sent to and from our 
servers.


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


Re: ActionError and JSP display

Posted by Jeff Beal <jb...@webmedx.com>.
Robin Mannering wrote:
> Hi,
> 
> 
> Platorm is : Tomcat 5, Struts 1.1
> 
> Context: HTML Form submissions and validation.
> 
> 
> I'm trying to conditionally test for the existince of error messages by their keys.  And I'd then like to show the error with HTML formatting around it.
> 
> 
> Basically, using tags, I'd like to do the same as the following following pseudo code.
> 
> 
> if (errorMessage named 'usernameError' exists) {
> 
> 	showError('usernameError' + some html)
> 
> }
> 
> 
> The error message is set from within the Form class as:
> 
> 
>     errors.add("usernameError", new ActionError("errors.form.username.required"));
> 
> 
> I've been trawling around and have found lots of references to <logic:messagesPresent> and then looping through each message using <html:messages> but not a test for the existence of a particular message.
> 
> 
> I'm trying to display the error message next to each appropriate form element rather than in a list.  I probably can't see the solution for looking.  Can anyone help?
> 
> 
> Many thanks
> 
> Robin

Read 
http://struts.apache.org/api/org/apache/struts/taglib/html/package-summary.html#doc.Other.errors,
paying attention to the property attribute of html:errors

-- Jeff