Hi Dave,
Thanks for that.. I will have a look at the VisitorValidator tomorrow (its 1 AM here :P ) I am sort of in the same position as you (using Hibernate objects at the web layer)... I have given that a thought before (annotating the hibernate objects with validation annotation). But that will tie up the hibernate objects to Struts, wouldnt it? Might not be a problem if the user of the object is just the webapp.. Anyway...just to clarify what you have there..: 1. Annotate the object with struts validation annotation. In my example, something like: public class Customer{ @RequiredStringValidator(message = "You must enter a value for username.") public String username; .... } 2. Annotate the Action class @Validation public class CustomerAction { public List<Customer> customer = new ArrayList<Customer>(); @Validations ( visitorFields = { @VisitorFieldValidator(fieldName = "customer ", message="", appendPrefix=true) } ) public String execute(){ } } And hopefully if everything works right, the validation should work? Not sure if I can eliminate the <s:fieldErrors/> ... since I'm using "simple" theme - my understanding is that with "simple" theme, I have to specifically write the actionErrors & fieldErrors. Could be wrong though... (I'm new to Struts 2). Also... with your @Validations above.. if you specify message="", wouldnt that create an extra empty error message? I experienced that before. Thanks again, and I'll let you know how I go with this tomorrow. Cheers. WiB. On 3/14/07, Dave Newton <[EMAIL PROTECTED]> wrote:
Just a quick followup regarding annotations: --- Dave Newton <[EMAIL PROTECTED]> wrote: > I don't know if this is a "better way" or not and it > does not use annotations (at least not yet), but... If you annotate the class contained in the collection the @VisitorFieldValidator still works. This won't work for me, because my class is being generated by HibernateTools (for now, anyway; I may switch to annotated POJOs) so I still need to use the XML validation config, but there you go. d. ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Best regards, WiB -------------------