Hello David, I think that the main problem in struts-validator is because is highly coupled with ActionForm. Ok, I can use commons-validator. But, my idea is:
* Put the validation rules in only one place (a XML file that can be read and interpretated by struts and my business rule); * The validation rule also has the type of a column (indicating if is boolean, data, String, BigDecimal, ... ); * The struts tags will generate JavaScript to validate the input of data; * My business rule will check if all data is ok again (because the user can turn off JavaScript). My business rule generaly receives a Value Object to insert or update data. My VO is dynamic - I say which columns and rows they will have. If I know the type of data that came from ActionForm (I always use String in ActionForms) I can convert on fly the data between ActionForm and VO. Theres is a sample example: ----- Action ------ MyValueObject vo = new MyValueObject( form ); // Works because I will know the types of columns in ActionForm - it's defined in XML MyBusinessObject bo = new MyBusinessObject(); bo.insert( vo ); ----- MyBusinessObject ----- public void insert( MyValueObject vo ) { if not checkIfAlwaysIsOk( vo ) { throw new Exception( "..." ); } insertIntoDatabase( ); // If a need to get some data from VO, I use - vo.get( lineNumber, columnNumber ) } public boolean checkIfAlwaysIsOk( vo ) { return Validator.checkIfRulesIsOk( vo, "file with xml definitions" ); // Validator is a generic class that will be used by struts-validator and my business rule } Thanks, Regis Melo ----- Original Message ----- From: "David Graham" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, February 01, 2003 7:03 PM Subject: Re: Validator and business rule > You can use the generic commons-validator in your business logic if you > want. The Struts version and the commons version can use the same xml > config file for the validation rules. > > David > > > > > > > >From: "Regis Melo" <[EMAIL PROTECTED]> > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Subject: Validator and business rule > >Date: Sat, 1 Feb 2003 18:23:00 -0300 > > > >Hello, > > > > Why Struts-validator is so highly coupled with ActionForms? I think > >that is a good idea to use struts-validator to do some work in my business > >classes. How can I do that? > > > >Thanks, > > > >Regis Melo > > > _________________________________________________________________ > Protect your PC - get McAfee.com VirusScan Online > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > > --------------------------------------------------------------------- > 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]