Re: Bug in order of error presentment (html:error)
There's no real difference between using one property name of your own choosing, and using the Struts GLOBAL_ERROR property name. It's mostly just a matter of choice. The only point I can think of is that you might want to differentiate between "things that are really global" and "things that are global now but might not be later". -- Martin Cooper - Original Message - From: "Jeff Trent" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 09, 2001 9:57 PM Subject: Re: Bug in order of error presentment (html:error) > Thanks for the input Martin. This is helpful. Just curious, what is the > advantage in using the property name as opposed to GLOBAL_ERROR? > > > - Original Message - > From: "Martin Cooper" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, May 10, 2001 12:02 AM > Subject: Re: Bug in order of error presentment (html:error) > > > > The order of errors for a given property name will be preserved. However, > > the error lists are stored in a HashMap with the property name as the key, > > so the iteration order of those is not defined. > > > > If you are just using (that is, you are not specifying the > > property attribute), then you might consider using a common property name, > > or just ActionErrors.GLOBAL_ERROR. That way, all of your errors will be > > preserved in the order in which you added them. > > > > Alternatively, you could use multiple instances of the tag, > > one for each property, like this: > > > > > > > > > > > > Given your example, this isn't very practical for your situation, but it > > might be useful in cases where multiple errors for each of a small number > of > > properties is typical. > > > > -- > > Martin Cooper > > > > > > - Original Message - > > From: "Jeff Trent" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, May 09, 2001 1:46 PM > > Subject: Bug in order of error presentment (html:error) > > > > > > In Form.Validate() > > { > > ... > > if (getCustomerContactName().length() <= 1) > > errors.add("customerContactName", new > > ActionError("error.customercontactname.required")); > > > > if (getCustomerContactPhone().length() <= 1) > > errors.add("customerContactPhone", new > > ActionError("error.customercontactphone.required")); > > > > if (getCustomerContactEmail().length() <= 1) > > errors.add("customerContactEmail", new > > ActionError("error.customercontactemail.required")); > > ... > > } > > > > In Properties file: > > error.customercontactname.required=Contact Name is a required > > field > > error.customercontactphone.required=Contact Phone is a required > > field > > error.customercontactemail.required=Contact Email is a required > > field > > > > Output from html:errors: > > Contact Phone is a required field > > Contact Name is a required field > > Contact Email is a required field > > > > > > Note the ordering. Name should have preceded Phone. > > > > > > > > > > >
Re: Bug in order of error presentment (html:error)
Thanks for the input Martin. This is helpful. Just curious, what is the advantage in using the property name as opposed to GLOBAL_ERROR? - Original Message - From: "Martin Cooper" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 10, 2001 12:02 AM Subject: Re: Bug in order of error presentment (html:error) > The order of errors for a given property name will be preserved. However, > the error lists are stored in a HashMap with the property name as the key, > so the iteration order of those is not defined. > > If you are just using (that is, you are not specifying the > property attribute), then you might consider using a common property name, > or just ActionErrors.GLOBAL_ERROR. That way, all of your errors will be > preserved in the order in which you added them. > > Alternatively, you could use multiple instances of the tag, > one for each property, like this: > > > > > > Given your example, this isn't very practical for your situation, but it > might be useful in cases where multiple errors for each of a small number of > properties is typical. > > -- > Martin Cooper > > > - Original Message - > From: "Jeff Trent" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, May 09, 2001 1:46 PM > Subject: Bug in order of error presentment (html:error) > > > In Form.Validate() > { > ... > if (getCustomerContactName().length() <= 1) > errors.add("customerContactName", new > ActionError("error.customercontactname.required")); > > if (getCustomerContactPhone().length() <= 1) > errors.add("customerContactPhone", new > ActionError("error.customercontactphone.required")); > > if (getCustomerContactEmail().length() <= 1) > errors.add("customerContactEmail", new > ActionError("error.customercontactemail.required")); > ... > } > > In Properties file: > error.customercontactname.required=Contact Name is a required > field > error.customercontactphone.required=Contact Phone is a required > field > error.customercontactemail.required=Contact Email is a required > field > > Output from html:errors: > Contact Phone is a required field > Contact Name is a required field > Contact Email is a required field > > > Note the ordering. Name should have preceded Phone. > > > > >
Re: Bug in order of error presentment (html:error)
The order of errors for a given property name will be preserved. However, the error lists are stored in a HashMap with the property name as the key, so the iteration order of those is not defined. If you are just using (that is, you are not specifying the property attribute), then you might consider using a common property name, or just ActionErrors.GLOBAL_ERROR. That way, all of your errors will be preserved in the order in which you added them. Alternatively, you could use multiple instances of the tag, one for each property, like this: Given your example, this isn't very practical for your situation, but it might be useful in cases where multiple errors for each of a small number of properties is typical. -- Martin Cooper - Original Message - From: "Jeff Trent" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 09, 2001 1:46 PM Subject: Bug in order of error presentment (html:error) In Form.Validate() { ... if (getCustomerContactName().length() <= 1) errors.add("customerContactName", new ActionError("error.customercontactname.required")); if (getCustomerContactPhone().length() <= 1) errors.add("customerContactPhone", new ActionError("error.customercontactphone.required")); if (getCustomerContactEmail().length() <= 1) errors.add("customerContactEmail", new ActionError("error.customercontactemail.required")); ... } In Properties file: error.customercontactname.required=Contact Name is a required field error.customercontactphone.required=Contact Phone is a required field error.customercontactemail.required=Contact Email is a required field Output from html:errors: Contact Phone is a required field Contact Name is a required field Contact Email is a required field Note the ordering. Name should have preceded Phone.
Re: Bug in order of error presentment (html:error)
Unless its implemented in terms of a hashtable, no. - Original Message - From: Nanduri, Amarnath To: '[EMAIL PROTECTED]' Sent: Wednesday, May 09, 2001 4:54 PM Subject: RE: Bug in order of error presentment (html:error) I don't think it is a bug. I think the is using an Iterator. there is no guarantee of ordering in an Iterator. Correct me if i am wrong. cheers, Amar.. -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: Wednesday, May 09, 2001 4:47 PMTo: [EMAIL PROTECTED]Subject: Bug in order of error presentment (html:error) In Form.Validate() { ... if (getCustomerContactName().length() <= 1) errors.add("customerContactName", new ActionError("error.customercontactname.required")); if (getCustomerContactPhone().length() <= 1) errors.add("customerContactPhone", new ActionError("error.customercontactphone.required")); if (getCustomerContactEmail().length() <= 1) errors.add("customerContactEmail", new ActionError("error.customercontactemail.required"));... } In Properties file: error.customercontactname.required=Contact Name is a required fielderror.customercontactphone.required=Contact Phone is a required fielderror.customercontactemail.required=Contact Email is a required field Output from html:errors: Contact Phone is a required fieldContact Name is a required fieldContact Email is a required field Note the ordering. Name should have preceded Phone.
RE: Bug in order of error presentment (html:error)
I don't think it is a bug. I think the is using an Iterator. there is no guarantee of ordering in an Iterator. Correct me if i am wrong. cheers, Amar.. -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: Wednesday, May 09, 2001 4:47 PMTo: [EMAIL PROTECTED]Subject: Bug in order of error presentment (html:error) In Form.Validate() { ... if (getCustomerContactName().length() <= 1) errors.add("customerContactName", new ActionError("error.customercontactname.required")); if (getCustomerContactPhone().length() <= 1) errors.add("customerContactPhone", new ActionError("error.customercontactphone.required")); if (getCustomerContactEmail().length() <= 1) errors.add("customerContactEmail", new ActionError("error.customercontactemail.required"));... } In Properties file: error.customercontactname.required=Contact Name is a required fielderror.customercontactphone.required=Contact Phone is a required fielderror.customercontactemail.required=Contact Email is a required field Output from html:errors: Contact Phone is a required fieldContact Name is a required fieldContact Email is a required field Note the ordering. Name should have preceded Phone.
Bug in order of error presentment (html:error)
In Form.Validate() { ... if (getCustomerContactName().length() <= 1) errors.add("customerContactName", new ActionError("error.customercontactname.required")); if (getCustomerContactPhone().length() <= 1) errors.add("customerContactPhone", new ActionError("error.customercontactphone.required")); if (getCustomerContactEmail().length() <= 1) errors.add("customerContactEmail", new ActionError("error.customercontactemail.required"));... } In Properties file: error.customercontactname.required=Contact Name is a required fielderror.customercontactphone.required=Contact Phone is a required fielderror.customercontactemail.required=Contact Email is a required field Output from html:errors: Contact Phone is a required fieldContact Name is a required fieldContact Email is a required field Note the ordering. Name should have preceded Phone.