My aim is to declare validators only once to be used on both sides and reuse the validator code. Some of them have to be coded in Java.
I am searching for the best way how to define validators in the .ds.xml file, which should be used on client and on server.
I've also checked http://forums.smartclient.com/showth...ght=validation , but still no idea how to actually do it.
Is there a best approach like how the buildin validators from SmartGWT are used?
Would be very nice if you can provide some code, please.
As far as I know:
Server validation can be achieved like this:
Client side validation can be achieved like this:
onModuleLoad(){
Validator.addValidatorDefinition("myCustomValidatorType", new Validator());
in ds.xml
I am searching for the best way how to define validators in the .ds.xml file, which should be used on client and on server.
I've also checked http://forums.smartclient.com/showth...ght=validation , but still no idea how to actually do it.
Is there a best approach like how the buildin validators from SmartGWT are used?
Would be very nice if you can provide some code, please.
As far as I know:
Server validation can be achieved like this:
Code:
<field name="quantity" type="integer"> <validators> <validator type="serverCustom"> <serverObject lookupStyle="new" className="com.smartgwt.sample.showcase.server.ValidatorDMI"/> <errorMessage>Only $available in stock</errorMessage> </validator> </validators> </field>
onModuleLoad(){
Validator.addValidatorDefinition("myCustomValidatorType", new Validator());
in ds.xml
Code:
<field name="quantity" type="integer"> <validators> <validator type="myCustomValidatorType"> <errorMessage>validation error</errorMessage> </validator> </validators> </field>
Comment