No, I don't agree with you.
My model is unchanged, containing validation rules, whether I use my
approach or standard Struts stuff.
I wouldn't have any validation rules in ActionForms if a could help it
except for the fact that, initially you need to store input as Strings so
that you can re-display what they user keyed in in the event of an error.
Using GenericActionForm and GenericBean I get rid of all the ActionForms and
"data" beans I had previously and can concentrate on the view (JSP's) and
model. For me it was alot less classes.
Thanks for your interest.
Niall
> -----Original Message-----
> From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
> Sent: 14 April 2001 01:46
> To: [EMAIL PROTECTED]
> Subject: RE: Action Forms And Model objects
>
>
> Niall,
> I guess your formula does reduce coding for ActionsForms which require
> simple validation & do not need to access the model for any type of
> validation, but I think you will still have to write a class for every
> form where you will create your validation rules. This does not eliminate
> the total number of classes vs. the total number of classes required by
> Struts. Please correct me if I did not get this right.
>
> Maybe you could use XML-Schema to define every rules for every form. Rules
> can be associated based upon a form name which is handed over to
> ActionServlet using a request parameter. The GenericActionForm can load
> the XMLSchema for the form & validate the the form input. Regardless, it
> is good idea & definetly worth pursuing with a purpose of reducing the
> number of classes required in the application implementation.
>
> Rajan Gupta
>
> --- Niall Pemberton <[EMAIL PROTECTED]> wrote:
> > I'm still developing/debugging it at the moment so its fairly
> > rudimentary at
> > the moment. I'm still considering how I could devlop it at the moment -
> > possibly your XML idea.
> >
> > I have extended Action and done some stuff in the perform method to cast
> > the
> > form and manage a connection and then call a processForm() method. Also
> > it
> > handles control with standard success & failure forwards but I'm looking
> > at
> > developing that as well - probably creating a transport object rather
> > than
> > just returning a String message key.
> >
> > A processForm() method validating input looks something like this:
> >
> > protected String processForm(HttpServletRequest request,
> > HttpServletResponse response,
> > GenericActionForm form,
> > Connection connection) throws Exception {
> >
> > // Validate the form
> > form.setRule("empl_id", true, form.INT); // required Integer
> > form.setRule("empl_name", true); // required String
> > form.setRule("empl_dob", true, form.DATE); // required date
> > form.setRule("empl_married", form.BOOLEAN); // optional Boolean
> > if (form.validateProperties() != null) {
> > return message;
> > }
> >
> > // Store values from the form in GenericBean(s)
> > GenericBean bean = form.createBean();
> >
> > // Process Business Logic
> > return message = new
> > LogicBuildProgram().createBuildProgram(connection,
> > bean);
> > }
> >
> > > -----Original Message-----
> > > From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
> > > Sent: 13 April 2001 13:32
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: Action Forms And Model objects
> > >
> > >
> > > How do you store or manage your validation rules since your
> > > GenericActionForm could be validating fields types of forms?
> > > --- Niall Pemberton <[EMAIL PROTECTED]> wrote:
> > > > > Niall-
> > > > > To understand it a little better, does it mean that you do not
> > allow
> > > > > ActionServlet to call the validate() method on your
> > GenericActionForm
> > > > > since u do your validation in Action instead? Or I missed
> > something!
> > > >
> > > > Yes.
> > > >
> > > > > Also, do you store your validation rules in some type of a XML
> > file or
> > > > > similar?
> > > >
> > > > No.
> > > >
> > > > > Further, I would imagine that your Action itself checks with the
> > model
> > > > for
> > > > > any incorrect data in the form if it needs to?
> > > >
> > > > Yes.
> > > >
> > > > > I guess u still derive GenericActionForm from ActionForm
> > > >
> > > > Yes.
> > > >
> > > > > -Rajan
> > > > > --- Niall Pemberton <[EMAIL PROTECTED]> wrote:
> > > > > > Normally you extend ActionForm and implement getters/setters for
> > > > each
> > > > > > property
> > > > > > e.g. public String getCustName()
> > > > > > public void setCustName(String name)
> > > > > >
> > > > > > I have a GenericActionForm which has some standard
> > getters/setters
> > > > > > e.g. public String getString(String property)
> > > > > > public void setString(String property, String value)
> > > > > >
> > > > > > GenericActionForm stores these property/value pairs in internal
> > > > arrays.
> > > > > > I
> > > > > > have customised ActionServlet to populate these and also
> > customised
> > > > some
> > > > > > of
> > > > > > the <html> tags to use the generic getter method if the form is
> > an
> > > > > > instance
> > > > > > of my GenericActionForm.
> > > > > >
> > > > > > I don't really know what you mean by "dynamic" validation of
> > > > properties.
> > > > > > When processing a GenericActionForm in the Action you can set up
> > > > rules
> > > > > > for
> > > > > > each of the properties to say whether it is required input and
> > what
> > > > data
> > > > > > type it should be. The form has a validate method to check whats
> > > > been
> > > > > > received agaist those rules. Its not dynamic but it is straight
> > > > forward.
> > > > > >
> > > > > > If the above checks fail, I can then re-display the form with
> > the
> > > > values
> > > > > > entered. If the checks pass I can then safely populate the data
> > into
> > > > > > beans
> > > > > > converting from Strings to the correct data types.
> > > > > >
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Levi Cook [mailto:[EMAIL PROTECTED]]
> > > > > > > Sent: 13 April 2001 01:05
> > > > > > > To: [EMAIL PROTECTED]
> > > > > > > Subject: Re: Action Forms And Model objects
> > > > > > >
> > > > > > >
> > > > > > > Can you elaborate on what you mean by "dynamic" properties?
> > > > > > >
> > > > > > > How does this refer to dynamic validation of properties?
> > > > > > >
> > > > > > > -- Levi
> > > > > > >
> > > > > > > ----- Original Message -----
> > > > > > > From: "Niall Pemberton" <[EMAIL PROTECTED]>
> > > > > > > To: <[EMAIL PROTECTED]>
> > > > > > > Sent: Thursday, April 12, 2001 5:58 PM
> > > > > > > Subject: RE: Action Forms And Model objects
> > > > > > >
> > > > > > >
> > > > > > > > We are currently building the following:
> > > > > > > >
> > > > > > > > 1) GenericActionForm with dynamic properties
> > > > > > > > 2) Override ActionServlet to populate the GenericActionForm
> > > > > > > > 3) Provide type validation & conversion mechanisms in the
> > > > > > > GenericActionForm
> > > > > > > > 4) Provide mechanism to unload the GenericActionForm into
> > > > > > GenericBeans
> > > > > > > >
> > > > > > > > Our Actions initiate form validation, unload data into
> > > > > > > GenericBeans which
> > > > > > > > are then passed to our logic layer and I believe this will
> > > > > > > allow us to put
> > > > > > > > most of our effort into developing the JSP's and logic
> > layer.
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: Natra, Uday [mailto:[EMAIL PROTECTED]]
> > > > > > > > > Sent: 12 April 2001 20:17
> > > > > > > > > To: '[EMAIL PROTECTED]'
> > > > > > > > > Subject: Action Forms And Model objects
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hi All,
> > > > > > > > > I want to know how you all are desiging the Datacopy from
> > > > > > ActionForm
> > > > > > > Beans
> > > > > > > > > to actual Model objects. In my opinion ActionForms should
> > have
> > > > > > only
> > > > > > > String
> > > > > > > > > DataTypes(Dates are represented as strings). But the Model
> > > > > > > objects have
> > > > > > > > > actual Data Types since they represent the actual Domain
> > > > > > > objects. If it
> > > > > > > is
> > > > > > > > > the case, we need to write code to copy the contents of
> > the
> > > > > > > > > ActionForm into
> > > > > > > > > the Domain Object as we cannot use the
> > > > > > > > > PropertyUtils.copyProperties(formBean, modelObject);
> > > > > > > > >
> > > > > > > > > Can anybody comment on this??
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > > Uday.
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Get email at your own domain with Yahoo! Mail.
> > > > > http://personal.mail.yahoo.com/
> > > > >
> > > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get email at your own domain with Yahoo! Mail.
> > > http://personal.mail.yahoo.com/
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
>