You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "emmanuel.boudrant" <b7...@yahoo.fr> on 2001/11/05 15:45:54 UTC

Question obout validator : ActionForm design

I would have a proposal concerning the ActionForm objects, currently
the proprietes of these objects owe beings of String.  Why not to
create a abstracts object ActionFormField with an abstract method
toString() to display and validate it correctly.
After to declare fields:
NameField extends ActionFormField 
DateField extends ActionFormField 
ZipCodeField extends ActionFormField
...
ex:
package com.cross.controller.formfield;

public class DateField extends FormField
{
   protected String jour = null;
   protected String mois = null;
   protected String annee = null;
   public DateField() { }

   // Set & Get ...

   ...
   public String toString() {
      if ( jour == null && mois == null && annee == null ) return null;
      return jour + "/" + mois + "/" + annee;
   }
}
With this solution, we can easily validate the fields according to its type.
 



---------------------------------
Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en français !

Re: Question obout validator : ActionForm design

Posted by Ted Husted <hu...@apache.org>.
Personally, I'm continually torn about doing something with the idea of
an ActionFormField. 

But I always come back to the concern that this starts to make the
ActionForm look too much like a model bean. 

The ActionForms really need to be transient objects, that serve the one
and only purpose of commuting the input up from HTTP and into the
application, where it can be handled by more capable objects. So, the
less work put into them the better. 

I think the least amount of work is to declare them as this or that in a
XML file, so a tag extension can use the same information for Javascript
validation. There are also other things to declare about an ActionForm,
like upon which page of workflow a property is collected (and
validated). 

Right now, keeping them as plain Strings and Booleans makes them HTTP
compatible, and easy to transfer using BeanUtil.populate.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/



"emmanuel.boudrant" wrote:
> 
> I would have a proposal concerning the ActionForm objects, currently
> the proprietes of these objects owe beings of String.  Why not to
> create a abstracts object ActionFormField with an abstract method
> toString() to display and validate it correctly.
> After to declare fields:
> NameField extends ActionFormField
> DateField extends ActionFormField
> ZipCodeField extends ActionFormField
> ...
> ex:
> package com.cross.controller.formfield;
> 
> public class DateField extends FormField
> {
>    protected String jour = null;
>    protected String mois = null;
>    protected String annee = null;
>    public DateField() { }
> 
>    // Set & Get ...
> 
>    ...
>    public String toString() {
>       if ( jour == null && mois == null && annee == null ) return null;
>       return jour + "/" + mois + "/" + annee;
>    }
> }
> With this solution, we can easily validate the fields according to its type.
> 
> 
> ---------------------------------
> Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en français !

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>