You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Vittor <da...@mystaff.com.au> on 2003/03/19 04:43:56 UTC

Strut your Stuff validation

Dear Struts World,

Hi! My name is David, and I'm writing to make a formal announcement about the validation package in the struts architecture.

Based on this article: Strut your Stuff http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html
it comes up with a very good architecture to do validation (although I18N would be nice also). Still a simple regular expresion attribute and an error message is nice. However I found that to implement it - a change to the struts source code is required!!! (This is sooo WRONG!!)

But as the struts architecture is only at a Candidate Release, I was wondering if along with the <validation:javascript> tag,  the html tag library could produce something simple (like something not requiring 10 lines of xml for every single fields input?) It's totally unmaintainable.

Can anyone help me?

D.A.V.


Re: Strut your Stuff validation

Posted by David Vittor <da...@mystaff.com.au>.
Hey David,

Thanks for that console, that may make development a little easier - I'll
look into it.

And yeah Jeff, it is simply a cut and paste after job with the xml
validation, but when you have over 100 editable forms in your application,
and over 1000 fields, well personally I'd rather not have all that xml code
to sift through just to do validation. The "pattern" attribute was good
(even though old - yes Dec2000), because it localised the validation to the
place where the struts html element existed.

Still I'll try this console thing. Thanks.
D.A.V.


----- Original Message -----
From: "Jeff Kyser" <kt...@comcast.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, March 20, 2003 10:15 AM
Subject: Re: Strut your Stuff validation


> Hey David,
>
> That article is from December 2000, is it not? I only briefly scanned
> it but I didn't have to do any of that stuff with customizing
> struts.jar,  etc.
> Have you checked out more recent stuff like the 'requiredif' rule, etc.?
>
> I'm with David Graham - find it very manageable indeed. I have the
> validator-rules.xml, a separate validator-custom-rules.xml where
> I've placed global constants like various masks and the few rules
> I've created (mostly for practice - example boolean and identical),
>   and then my webapp-specific validation.xml file containing the mappings
> for individual form elements.
>
> So really, all I have to do for a new webapp is the form-specific
> mappings, and those tend to be cut-n-paste from *somewhere* a
> after you've done enough of them...
>
> regards,
>
> -jeff
>
> On Wednesday, March 19, 2003, at 05:04  PM, David Vittor wrote:
>
> > Thanks for replying Jeff.
> >
> > Well as the article suggested I added the Validator interface to the
> > BaseFieldTag.java class, via the below code:
> >     Object pagebean = pageContext.findAttribute(name);
> >     if(pagebean instanceof com.bank.Validator) {
> >         ((com.bank.Validator) pagebean).setPattern(property, pattern);
> >         ((com.bank.Validator) pagebean).setErrorMessage(property,
> > errorMessage);
> >     }
> >
> > This compiled, and along with the Validator interface I than create a
> > new
> > struts.jar file, and it proved the example worked - but it felt so
> > wrong,
> > almost suicidal (in programming terms :)
> >
> > I have managed to get around this by using my own custom tags library
> > (i.e.
> > my:text and my:password - which extend of html:text and html:password)
> > . But
> > it's fortunate I'm only worried about textBox components, otherwise
> > lack of
> > multiple inheritance in java would also have got me.
> >
> > All I'm basically saying is that maybe there should be more than one
> > validation scheme in the struts architecture - a simple one ("for
> > dummies"
> > like me :) and a more complicated one, which can be used by those
> > companies
> > with a big piggy bank.
> >
> > D.A.V.
> >
> > P.S. I'm a big fan of intelligent users providing intelligent input,
> > but my
> > boss is very anti user intelligence :)
> >
> >
> >
> >> I'm curious as to what change you had to make to the struts source
> >> code?
> >>
> >> I certainly haven't had to do that, although I thought it was pretty
> >> slick to be able to extend the framework by providing your own
> >> rules...
> >>
> >> The XML can be a little verbose, but to quote a Dire Straits song,
> >> you don't get 'your money for nothin' and chicks for free'...
> >>
> >> http://www.ada.com.tr/~modabasi/dslyr6.htm#8
> >>
> >> I  guess if you didn't want to 'clutter your XML', you could just
> >> rely on the user to provide valid inputs :)
> >>
> >> -jeff
> >>
> >> On Tuesday, March 18, 2003, at 09:43  PM, David Vittor wrote:
> >>
> >>> Dear Struts World,
> >>>
> >>> Hi! My name is David, and I'm writing to make a formal announcement
> >>> about the validation package in the struts architecture.
> >>>
> >>> Based on this article: Strut your Stuff
> >>> http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html
> >>> it comes up with a very good architecture to do validation (although
> >>> I18N would be nice also). Still a simple regular expresion attribute
> >>> and an error message is nice. However I found that to implement it -
> >>> a
> >>> change to the struts source code is required!!! (This is sooo
> >>> WRONG!!)
> >>>
> >>> But as the struts architecture is only at a Candidate Release, I was
> >>> wondering if along with the <validation:javascript> tag,  the html
> >>> tag
> >>> library could produce something simple (like something not requiring
> >>> 10 lines of xml for every single fields input?) It's totally
> >>> unmaintainable.
> >>>
> >>> Can anyone help me?
> >>>
> >>> D.A.V.
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
> ---------------------------------------------------------------------
> 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


Re: Strut your Stuff validation

Posted by Jeff Kyser <kt...@comcast.net>.
Hey David,

That article is from December 2000, is it not? I only briefly scanned
it but I didn't have to do any of that stuff with customizing 
struts.jar,  etc.
Have you checked out more recent stuff like the 'requiredif' rule, etc.?

I'm with David Graham - find it very manageable indeed. I have the
validator-rules.xml, a separate validator-custom-rules.xml where
I've placed global constants like various masks and the few rules
I've created (mostly for practice - example boolean and identical),
  and then my webapp-specific validation.xml file containing the mappings
for individual form elements.

So really, all I have to do for a new webapp is the form-specific
mappings, and those tend to be cut-n-paste from *somewhere* a
after you've done enough of them...

regards,

-jeff

On Wednesday, March 19, 2003, at 05:04  PM, David Vittor wrote:

> Thanks for replying Jeff.
>
> Well as the article suggested I added the Validator interface to the
> BaseFieldTag.java class, via the below code:
>     Object pagebean = pageContext.findAttribute(name);
>     if(pagebean instanceof com.bank.Validator) {
>         ((com.bank.Validator) pagebean).setPattern(property, pattern);
>         ((com.bank.Validator) pagebean).setErrorMessage(property,
> errorMessage);
>     }
>
> This compiled, and along with the Validator interface I than create a 
> new
> struts.jar file, and it proved the example worked - but it felt so 
> wrong,
> almost suicidal (in programming terms :)
>
> I have managed to get around this by using my own custom tags library 
> (i.e.
> my:text and my:password - which extend of html:text and html:password) 
> . But
> it's fortunate I'm only worried about textBox components, otherwise 
> lack of
> multiple inheritance in java would also have got me.
>
> All I'm basically saying is that maybe there should be more than one
> validation scheme in the struts architecture - a simple one ("for 
> dummies"
> like me :) and a more complicated one, which can be used by those 
> companies
> with a big piggy bank.
>
> D.A.V.
>
> P.S. I'm a big fan of intelligent users providing intelligent input, 
> but my
> boss is very anti user intelligence :)
>
>
>
>> I'm curious as to what change you had to make to the struts source 
>> code?
>>
>> I certainly haven't had to do that, although I thought it was pretty
>> slick to be able to extend the framework by providing your own 
>> rules...
>>
>> The XML can be a little verbose, but to quote a Dire Straits song,
>> you don't get 'your money for nothin' and chicks for free'...
>>
>> http://www.ada.com.tr/~modabasi/dslyr6.htm#8
>>
>> I  guess if you didn't want to 'clutter your XML', you could just
>> rely on the user to provide valid inputs :)
>>
>> -jeff
>>
>> On Tuesday, March 18, 2003, at 09:43  PM, David Vittor wrote:
>>
>>> Dear Struts World,
>>>
>>> Hi! My name is David, and I'm writing to make a formal announcement
>>> about the validation package in the struts architecture.
>>>
>>> Based on this article: Strut your Stuff
>>> http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html
>>> it comes up with a very good architecture to do validation (although
>>> I18N would be nice also). Still a simple regular expresion attribute
>>> and an error message is nice. However I found that to implement it - 
>>> a
>>> change to the struts source code is required!!! (This is sooo 
>>> WRONG!!)
>>>
>>> But as the struts architecture is only at a Candidate Release, I was
>>> wondering if along with the <validation:javascript> tag,  the html 
>>> tag
>>> library could produce something simple (like something not requiring
>>> 10 lines of xml for every single fields input?) It's totally
>>> unmaintainable.
>>>
>>> Can anyone help me?
>>>
>>> D.A.V.
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: Strut your Stuff validation

Posted by David Vittor <da...@mystaff.com.au>.
Thanks for replying Jeff.

Well as the article suggested I added the Validator interface to the
BaseFieldTag.java class, via the below code:
    Object pagebean = pageContext.findAttribute(name);
    if(pagebean instanceof com.bank.Validator) {
        ((com.bank.Validator) pagebean).setPattern(property, pattern);
        ((com.bank.Validator) pagebean).setErrorMessage(property,
errorMessage);
    }

This compiled, and along with the Validator interface I than create a new
struts.jar file, and it proved the example worked - but it felt so wrong,
almost suicidal (in programming terms :)

I have managed to get around this by using my own custom tags library (i.e.
my:text and my:password - which extend of html:text and html:password) . But
it's fortunate I'm only worried about textBox components, otherwise lack of
multiple inheritance in java would also have got me.

All I'm basically saying is that maybe there should be more than one
validation scheme in the struts architecture - a simple one ("for dummies"
like me :) and a more complicated one, which can be used by those companies
with a big piggy bank.

D.A.V.

P.S. I'm a big fan of intelligent users providing intelligent input, but my
boss is very anti user intelligence :)



> I'm curious as to what change you had to make to the struts source code?
>
> I certainly haven't had to do that, although I thought it was pretty
> slick to be able to extend the framework by providing your own rules...
>
> The XML can be a little verbose, but to quote a Dire Straits song,
> you don't get 'your money for nothin' and chicks for free'...
>
> http://www.ada.com.tr/~modabasi/dslyr6.htm#8
>
> I  guess if you didn't want to 'clutter your XML', you could just
> rely on the user to provide valid inputs :)
>
> -jeff
>
> On Tuesday, March 18, 2003, at 09:43  PM, David Vittor wrote:
>
> > Dear Struts World,
> >
> > Hi! My name is David, and I'm writing to make a formal announcement
> > about the validation package in the struts architecture.
> >
> > Based on this article: Strut your Stuff
> > http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html
> > it comes up with a very good architecture to do validation (although
> > I18N would be nice also). Still a simple regular expresion attribute
> > and an error message is nice. However I found that to implement it - a
> > change to the struts source code is required!!! (This is sooo WRONG!!)
> >
> > But as the struts architecture is only at a Candidate Release, I was
> > wondering if along with the <validation:javascript> tag,  the html tag
> > library could produce something simple (like something not requiring
> > 10 lines of xml for every single fields input?) It's totally
> > unmaintainable.
> >
> > Can anyone help me?
> >
> > D.A.V.
> >
>
>
> ---------------------------------------------------------------------
> 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


Re: Strut your Stuff validation

Posted by Jeff Kyser <kt...@comcast.net>.
I'm curious as to what change you had to make to the struts source code?

I certainly haven't had to do that, although I thought it was pretty
slick to be able to extend the framework by providing your own rules...

The XML can be a little verbose, but to quote a Dire Straits song,
you don't get 'your money for nothin' and chicks for free'...

	http://www.ada.com.tr/~modabasi/dslyr6.htm#8

I  guess if you didn't want to 'clutter your XML', you could just
rely on the user to provide valid inputs :)

-jeff

On Tuesday, March 18, 2003, at 09:43  PM, David Vittor wrote:

> Dear Struts World,
>
> Hi! My name is David, and I'm writing to make a formal announcement 
> about the validation package in the struts architecture.
>
> Based on this article: Strut your Stuff 
> http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-struts_p.html
> it comes up with a very good architecture to do validation (although 
> I18N would be nice also). Still a simple regular expresion attribute 
> and an error message is nice. However I found that to implement it - a 
> change to the struts source code is required!!! (This is sooo WRONG!!)
>
> But as the struts architecture is only at a Candidate Release, I was 
> wondering if along with the <validation:javascript> tag,  the html tag 
> library could produce something simple (like something not requiring 
> 10 lines of xml for every single fields input?) It's totally 
> unmaintainable.
>
> Can anyone help me?
>
> D.A.V.
>


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