Eric Beaumier wrote:
Hi guys,
I have a question regarding the order of using Commons-Validator in
Struts 1.1. Actually Struts feed the FORM before doing validation on
this one. Because the FORM must not throw exception during this
feeding, usually your FORMBEAN use only String datatype as setter/getter.
But in the case I receive a Composite Value Object from EJB, using a
complexe structure with beans using differents datatypes (String,
boolean, long , BigDecimal, ...), I can't use it directly with Nested
Tag for editing. Because I can't validate input before feeding a
BigDecimal for example! If the user enter "hello" in Textbox where it
suppose to be a BigDecimal, an Exception is Throw ...
note what you called your object - you called it a "Composite Value
Object". Ok, that's cool - still, it's a Value Object. Forms are not
meant to be VOs; nor are VOs supposed to be used as forms. Forms *only*
exist to give a "limbo" area for data to sit, in exactly the same state
as the user placed it there, until the form passes validation. Only
once the form passes validation should your data be copied from the form
to your VO. If you use the EJB as your VO, you will not be able to
preserve user input because - just like the case you described - some
fields might complain about the values that get assigned to them and
cause the user input to be lost.
Do you will look to add option to do the validation on the Request
object first?
I don't really see the need. Your VO should always contain valid data.
Like this, we can do the unit validation accordingly the
validation.xml and when all unit validation is done, you can feed the
FORM ... Nested Tag will redisplay the value from Request object at
the place of FormBean getter.
Give me your feedback ...
Thanks.
--
Eddie Bush
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>