Hi listers,

I have been working on this issue for the last couple of days but haven't 
found any satisfactory answers through the usual channels (mailing list 
archives, API, and some source code perusal as well).

As I understand it, post struts 1.1, ActionErrors were supposed to keep 
their FIFO ordering. I have tried a nightly from 2004-01-27 and just 
recently 2004-03-23 and here's what I experience:

* all of my forms extend ValidatorForm
* In one of those forms I override the validate method which first makes a 
call to super.validate()
* If the above call returns any errors, I wanted to stick a "prefix 
(or suffix) message" in front of the errors shown by validator. For the 
sake of simplicity, the rest of discussion will focus on adding a suffix 
message (as its a lot easier to describe how I added the suffix message).

So, instead of seeing the regular (boring :-)) messages from validator 
like:

* 'Postal Code' is a required field.
* 'City' is a required field.

the user would instead see:

* 'Postal Code' is a required field.
* 'City' is a required field.
* Invalid and/or incomplete input. Please provide the correct information 
as instructed:

Here's a look at the errors object from the debug log before the insertion 
of the "suffix message".

{
        postalCode=[errors.required[Postal Code, null, null, null]],
        city=[errors.required[City, null, null, null]]
}

(BTW, to make the message appear before the other ones as a prefix, I had
to create a new errors object and then add the original ones to it).

So the following code line example just tries to add an ActionMessage 
with resource "errors.validator.prefix [sic]" at the end.

So, after making my super.validate() call, I added a call to:

errors.add(ActionMessages.GLOBAL_MESSAGE,
        new ActionMessage("errors.validator.prefix"));

I would have expected the above line to just add a 3rd property at the 
end. Unfortunately, the errors object now looks like:

{
        postalCode=[errors.required[Postal Code, null, null, null]],
        org.apache.struts.action.GLOBAL_MESSAGE=[errors.validator.prefix[]],
        city=[errors.required[City, null, null, null]]
}

(Notice the GLOBAL_MESSAGE property stuck in the middle)

With the result being that the user sees:

* 'Postal Code' is a required field.
* Invalid and/or incomplete input. Please provide the correct information 
as instructed:
* 'City' is a required field.

Did I understand the FIFO capability of ActionErrors incorrectly? If this 
helps any, postalCode is one of the only few fields that I have discovered 
in all of my forms which "bubbles" up to the top.

Any help is appreciated.

Thanks,
--
Haroon Rafique
<[EMAIL PROTECTED]>


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

Reply via email to