Rooney.Dave wrote:
-----Original Message-----to do
From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: February 14, 2005 8:39 AM
To: Struts Users Mailing List
Subject: Re: Validation Strategies?
What I'm suggesting would not cause duplicate validation logic. The (business) validation logic is still performed in the manager layer (no matter the client). What I'm suggesting is simply a strategy
something similar to what Vic suggested, which is to map exceptions related to properties to bundle messages (if not as strong a coupling as Vic suggested). You *would* have to set up something morefor
your Swing client as far as renderer value-fetching goes (I use nearlythe
identical strategy in my Swing clients -- mapping error codes to bundle messages), but it wouldn't cause duplicate business validation. Just to make sure I made my suggestion clearly.
Good luck,
Erik
Erik,
OK - I misunderstood your previous reply a bit. Sorry...
The problem isn't so much the error messages, but associating them with the GUI controls.
Our Swing application handles its validation differently from the web apps... The application has a 'tabbed' interface, but we force a validation and save any time the user changes tabs.
In the web world, we have also a 'tabbed' interface, but the validation
is performed when the user explicitly performs a save. This, BTW, is at
the request of the users, who want to be able to do semi-heads down data
entry and perform validation at the end. So, the validation is applied
to all data entered in all tabs, so we need some way of associating an
error at least with a specific tab.
For example, a Client has an Address, the City in that address model is
mandatory. We also have the concept of Associates to a Client, who also
have addresses, and the City is mandatory there as well. The Client
information is on a separate tab from the Associate information. If the
user doesn't enter a City in the Address on one of those tabs, how would
you approach taking a validation error from way down in the domain model
for the address and indicating to the user the specific tab on which the
City wasn't entered?
I assume that you are speaking of your Web interface here, and not your Swing interface. The way the Validator plugin works, is that it uses a Map full of error messages which are keyed to properties. This Map is stored as a request attribute that the tags (html:errors, html:messages) can access so that you can determine down to the property what the errors are. If you want to, then, with the Validator plugin, it is easy to not only render general messages (at the top of your GUI), but to render each relevant message next to a specific form field.
So, taking a cue from this, you can set up ActionMessages, or some similar Map-backed structure, which gives you exceptions keyed to properties (and also keyed to bundle messages -- but using a different bundle from the Validator plugin's bundle if the Validator plugin is used) This presumes that your manager layer can "throw multiple exceptions at once" -- which can be done by chaining Exceptions, writing a custom Exception that holds a Map of other exceptions, error codes, etc.
To make a long story short, I use ActionMessages and chained exceptions for this.
Perhaps you are looking for something more "out of the box" than this; I don't know of anything right off.
Hope that helps, Erik
Let's complicate things a bit more... In both of those situations (Client and Associate), the user can enter multiple addresses, e.g. Home, Business, Mailing, etc. How do you associate a validation error in one of those address instances with the particular instance in the presentation?
Thanks!
Dave Rooney Secure Systems Development [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]