I think it is reasonable to have a feature request to
have ActionError have a constructor that takes an
Object array since especially since MessageResources
can do this.  So you could either send a proposal to
the e-mail list or the better place would probably be
to submit the request through bugzilla so it doesn't
get lost.  

As far as having more than four args, I think this was
a decision based on how many args to support in the
tags, but I'm not sure.  The MessageResources
getMessage(Locale locale, String key, Object args[])
directly passes in the object array to an instance of
java.text.MessageFormat.  So if ActionError could take
an Object[] then it could call the method in
MessageResources that takes an array and it doesn't
look like MessageFormat has any limitations for the
number of arguments it can handle.

David

--- William Jaynes <[EMAIL PROTECTED]> wrote:
> David,
> 
> Barracuda does this nested Exception procedure (as I
> believe you
> probably know already). I've been playing with their
> forms package a bit
> in a Struts app of mine. I like the scheme, in
> general, but the problem
> I have with their particular implementation is as
> follows... The
> Validator classes that throw the
> ValidationExceptions set the exception
> message to be a resource key. At some point in the
> Action class I check
> for validation exceptions and iterate through any
> that exist. I use
> getMessage() to get the key and add a new
> ActionError to the
> ActionErrors object. The problem comes with messages
> that need
> substitutions. If I have a resource message like
> "Date should be between
> {0} and {1}" I need some scheme for the Validator
> class to communicate
> the specific parameters that go along with the
> resource key. Seems to me
> that the ValidationException class needs a property
> like
> MessageArguments (possibly an array of Objects,
> since that is ultimately
> what MessageResources needs) that the Validator
> class can set and the
> Action class can get as it iterates through the
> exceptions.
> 
> I've coded extensions to the Barracuda classes for
> this, but it's
> awkward and means I need to always use my own
> versions of Validator
> classes.
> 
> On the Struts side of things, I find that if I have
> a resource key and
> an array of Objects that are the substitutions to be
> used in the
> message, there's no ActionError constructor that
> will let me pass in the
> array. Instead I have to manipulate things and use
> one of the existing
> constructors that specify each replacement value
> explicitly. Of course I
> could extend and make my own, but it seems
> reasonable that ActionError
> should have such a constructor. It would also permit
> more than 4
> substitutions, if anyone would need more.
> 
> Just my thoughts,
> Will
> 
> 
> ----- Original Message -----
> From: "David Winterfeldt" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, June 20, 2001 3:05 AM
> Subject: Re: validation in the form vs. validation
> in the business
> domain object
> 
> 
> > Someone I know extended Exception and they throw
> > nested exceptions that eventually are passed back
> to
> > the Struts layer and then an ActionError is
> > constructed for each exception.  Something like
> that
> > seems like a clean way to keep things separated. 
> I
> > did something similiar on a project with a Swing
> and
> > EJBs.
> >
> > David
> >
> > --- James Hoffa <[EMAIL PROTECTED]> wrote:
> > > What ideas do people have about where is the
> best
> > > place to perform validation of items that come
> back
> > > from ActionForms?
> > >
> > > Example: check to see if the user's choice of
> > > motherboard, memory, and cpu are compatible with
> > > each
> > > other.
> > >
> > > Following the struts example, it seems like the
> > > validate() method in an ActionForm is used only
> for
> > > light validation (i.e. checking to see if
> something
> > > was left blank, or checking for alpha and
> numeric
> > > chars). This approach seems correct to me, since
> > > there
> > > should not be business logic inside the
> ActionForm.
> > >
> > > That leaves most of the work to the business
> domain
> > > object since any nontrivial application will not
> > > have
> > > business logic in the Action class either.
> > >
> > > The business domain object, in many cases, will
> be
> > > accessed remotely from the Action class.
> > >
> > > Does it make sense for the business domain
> object to
> > > return an ActionErrors object(it is
> serializable)?
> > > I
> > > am not 100% comfortable yet with the idea of
> > > importing
> > > ActionErrors into the business object since it
> > > couples
> > > it to struts to a certain extent, and it could
> > > potentially be large.
> > >
> > > Is the only alternative to send back a list of
> > > generic
> > > error codes from the business object that each
> map
> > > to
> > > an ActionError and the Action class could add
> the
> > > ActionErrors? (i think i'd  rather import
> > > actionerrors
> > > in this case)
> > >
> > > What are some of the "best practices" people
> have
> > > found to work for this problem?
> > >
> > > Craig and ALL Struts creators:  Struts is really
> > > great. Thank you for all of your hard work. It
> is
> > > definitely something to be proud of.
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Get personalized email addresses from Yahoo!
> Mail
> > > http://personal.mail.yahoo.com/
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to