struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Regis Melo" <regisfm...@softsite.com.br>
Subject Re: Validator and business rule
Date Sun, 02 Feb 2003 14:57:38 GMT
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" <dgraham1980@hotmail.com>
To: <struts-user@jakarta.apache.org>
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" <regisfmelo@softsite.com.br>
> >Reply-To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> >To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> >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: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message