You seem to have missed the point about my response.

In this section :

if(!password.equals(username))  {
   //Add whatever action error here,
   //and it will be returned to the input page.

}

The action error that you create will contain the message you want. Just select or create the message
that you need. It will be returned to the page. You of course need to define the text in the message resource properties first.
I understand that this is only a code snippet and may only serve to confuse you, if this is the case have a look at some of the samples(source, specifically
classes which extend ActionForm) that come with of Struts.





James JKE95 Kerridge wrote:


Kwok,

thanks for the reply.

My problem is not as simple as that.

What I want to do is display a single error which relates to 2 different fields.

In the view I wish to highlight both of the fields that are in error and display only 1 error message that relates to both. Not just 1.

As this must be a standard requirement I was wondering how others have implemented this and whether there is a 'standard' approach that might be followed/copied.

Cheers

James



From: Kwok Peng Tuck <[EMAIL PROTECTED]> on 18/08/2003 10:06 ZE8
Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
cc: Subject: Re: Displaying a single error message for multiple properties


What you want to acheive is not impossible.

In your action form you just need to handle this in your validate method.
It's pretty simple :

if(!password.equals(username))  {
   //Add whatever action error here,
   //and it will be returned to the input page.
}



There's no need for you to write special taglibs to do this, as there is already a <html:error> tag that does this.



James JKE95 Kerridge wrote:



Basically I want to be able to raise a single ActionError for 2 properties.

e.g.

a password field and a confirm password field exist

if they don't match then I want to display one message saying "Password and confirmation password don't match"

I also want to highlight both fields.

To highlight both fields I would ideally raise a single error for each property.

Sadly the model doesn't seem to support multiple properties for a single error.

It seems that my choices will be to create a dodgy convention when

raising

messages and have a special tag lib for displaying them.

Has anyone found a nice way of doing this. It must a problem everyone has




faced because surely most web apps have cross field validation and want

to

have a single error message that relates to the fields involved in the cross validation. e.g. field B cannot be foo when field A is bar.

Cheers

James

*******************Confidentiality and Privilege

Notice*******************


This email is intended only to be read or used by the addressee. It is confidential and may contain legally privileged information. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone, and you should destroy this message and kindly notify the sender by reply email. Confidentiality and legal privilege are not waived or lost by
reason of mistaken delivery to you.


Qantas Airways Limited
ABN 16 009 661 901

Visit Qantas online at http://www.qantas.com.au








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






*******************Confidentiality and Privilege Notice*******************


This email is intended only to be read or used by the addressee. It is confidential and may contain legally privileged information. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone, and you should destroy this message and kindly notify the sender by reply email. Confidentiality and legal privilege are not waived or lost by
reason of mistaken delivery to you.


Qantas Airways Limited
ABN 16 009 661 901

Visit Qantas online at http://www.qantas.com.au






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



Reply via email to