You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neal Kaiser <ne...@makeastore.com> on 2001/02/05 05:52:58 UTC

Data Validation

Has anyone thought about adding data validation tags to the Struts taglibs?

For example, what if we could do:

<form:text property="username" required="true" validationtype="varchar" />

or something like that.

Could it not generate the necessary javascript, as well as provide an easy
to use
interface for detecting and reporting errors in the Action.perform()?

Just wondering...  Where do people typically do their validation? In the
ActionServlet
or ActionForm? Are there any pros/cons?

Thanks,
Neal


Re: Data Validation

Posted by Ted Husted <ne...@husted.com>.
These items are on the TODO list for the 1.1 timeframe. 

+ Client Side Validation. Add the ability to automatically generate
optional JavaScript code to perform client-side validations for things
like required fields, numeric fields, dates/times/timestamps, and so
on. The required validation should mesh with validation enhancements
provided in the controller servlet itself.

 + Standard Validations. Add the ability to configure standard
validations on particular properties to be enforced by the controller
servlet automatically. Where feasible, client-side JavaScript
validations may also be generated based on the same configuration
rules.


*********** REPLY SEPARATOR  ***********

On 2/5/2001 at 6:07 PM Jim Richards wrote:

>>Has anyone thought about adding data validation tags to the Struts
taglibs?
>
>This came up quite some time ago. I have a requirement for this sort
>of thing, and posted a library with example for doing validation
>(not sure where it is now).
>
>It work on the client side in JavaScript and you specify the 
>function you want to use for validation, and the message 
>to display, it piles them all up and displays it in a window.alert()
>with all the errors, and jumps to the first field with the
>error. It mostly works as there are some freaky things with hidden
>fields it doesn't like.



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/



Re: Data Validation

Posted by Jim Richards <gr...@cyber4.org>.
>Has anyone thought about adding data validation tags to the Struts taglibs?

This came up quite some time ago. I have a requirement for this sort
of thing, and posted a library with example for doing validation
(not sure where it is now).

It work on the client side in JavaScript and you specify the 
function you want to use for validation, and the message 
to display, it piles them all up and displays it in a window.alert()
with all the errors, and jumps to the first field with the
error. It mostly works as there are some freaky things with hidden
fields it doesn't like.

Re: Data Validation

Posted by bram <br...@info.nl>.
I think the regular expression version (eg
http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html )

is much better, becouse jou can easely write a client side validation with
the same regexp. ( have it working except for the stupid checkboxes and
radio buttons in ie4+, I keep "losing" my properties)and the regexp object
is part of javascript since version 1.1(I thought, browser NS3+, ie4+).


----- Original Message -----
From: "Neal Kaiser" <ne...@makeastore.com>
To: <st...@jakarta.apache.org>
Sent: Sunday, February 04, 2001 8:52 PM
Subject: Data Validation


> Has anyone thought about adding data validation tags to the Struts
taglibs?
>
> For example, what if we could do:
>
> <form:text property="username" required="true" validationtype="varchar" />
>
> or something like that.
>
> Could it not generate the necessary javascript, as well as provide an easy
> to use
> interface for detecting and reporting errors in the Action.perform()?
>
> Just wondering...  Where do people typically do their validation? In the
> ActionServlet
> or ActionForm? Are there any pros/cons?
>
> Thanks,
> Neal
>


Re: Data Validation

Posted by Ted Husted <ne...@husted.com>.
On 2/4/2001 at 11:52 PM Neal Kaiser wrote:
>Just wondering...  Where do people typically do their validation? In
the
>ActionServlet or ActionForm? Are there any pros/cons?

Validation is still rather controversial. Some people bypass the Struts
mechanism completely. 

Typically, you would start by validating the type and range of data in
ActionForm. Once that passes, you might need to do some further
"business logic" validation in the ActionServlet; for example, to check
a login from a database. 


*********** REPLY SEPARATOR  ***********


>Has anyone thought about adding data validation tags to the Struts
taglibs?
>
>For example, what if we could do:
>
><form:text property="username" required="true"
validationtype="varchar" />
>
>or something like that.
>
>Could it not generate the necessary javascript, as well as provide an
easy
>to use
>interface for detecting and reporting errors in the Action.perform()?
>
>Just wondering...  Where do people typically do their validation? In
the
>ActionServlet
>or ActionForm? Are there any pros/cons?
>
>Thanks,
>Neal



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/