You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Alexey Cheremisin <or...@zelan.ru> on 2003/09/03 13:12:44 UTC

forms validation in velocity context

Hello,

I needs any helper tools to validate html forms in velocity.

I see what the native turbine applications can use Intake service for 
this purpose but I can't initialize it in jetspeed.
Also I found bug  9757 with same problem and I know what Mr. Tailor 
developed another validator.
If the  Jetspeed Validator works when where can I find any examples or 
docs to using it?

Thanks for any tips.

Best regards,
Alexey Cheremisin.




Re: forms validation in velocity context

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Wednesday, September 3, 2003, at 04:12  AM, Alexey Cheremisin wrote:

> Hello,
>
> I needs any helper tools to validate html forms in velocity.
>
> I see what the native turbine applications can use Intake service for  
> this purpose but I can't initialize it in jetspeed.
> Also I found bug  9757 with same problem and I know what Mr. Tailor  
> developed another validator.
> If the  Jetspeed Validator works when where can I find any examples or  
> docs to using it?
>
> Thanks for any tips.
>
My name is David and Im not a tailor ;-)

The Jetspeed Validation code was a quick and dirty implementation I did  
last year under a small budget.
In your code, you have to use Turbine's parameter parser, such as in a  
doSave action:

...
rundata.getParameters().setProperties(businessObject);

The validator is automatically called from setProperties

In your business object, you have several options for validation
To have validation methods for each field that you want validated, you  
must write a method called validate[PropertyName], for example:

void setName(String name)
String getName()
boolean validateName(String name)

Or you can write one general validate method in your business object,  
which is called after all others:

boolean validate()

Otherwise, a default validator is called based on data type.
By default, it checks for alphanumeric data using a regex that tries to  
remove any javascript or other malicious looking input fields

Lastly don't forget to set the validation parameter passing in your  
TR.p (its currently commented out)

#services.RunDataService.default.parameter.parser=org.apache.jetspeed.ut 
il.parser.ValidationParameterParser

Its kind of half completed, the goal was to use XML descriptor files or  
Intake (which I gave up on).
Eventually, I'd like to integrate with the commons validator in the  
future, since it does basically the same thing, and like Struts, use  
XML-configuration-based validation.


--
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
+01 707 773-4646
+01 707 529 9194