I think you can Check the "tapestry.js" file, it will give you a lot of 
exemples of how to register a new validation method.

I think you only have to contribute to the Tapestry.validator object adding 
your own method using the "addValidator" method on Tapestry object.
So you have to add your own Js file that will do the job.

But I didn't test it...

-----Message d'origine-----
De : Angelo Chen [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 21 mars 2008 15:32
À : users@tapestry.apache.org
Objet : RE: T5: contributing a validator?


Hi Christophe,

Thanks, it works, here is a new validator, it's working but seems lacking
something in javascript, always has this pop up: function
Tapestry.validator.empty() does not exist for field 'name', any idea how to
add this to the js? thanks.

A.C.

public class Empty extends AbstractValidator<Void, Object> {

    public Empty() {
        super(null, Object.class, "empty");
    }

    public void validate(Field field, Void aVoid, MessageFormatter
messageFormatter, Object o) throws ValidationException {
        String s = o.toString();
        if (s == null || s.length() == 0)
            throw new ValidationException(buildMessage(messageFormatter,
field));
    }

    public void render(Field field, Void aVoid, MessageFormatter
messageFormatter, MarkupWriter markupWriter, FormSupport formSupport) {
        formSupport.addValidation(field, "empty",
buildMessage(messageFormatter, field), null);
    }

    private String buildMessage(MessageFormatter formatter, Field field)
    {
        return formatter.format(field.getLabel());
    }
}



Cordenier Christophe wrote:
>
> Hello
>
> You have to specify a constraint : validate="require,uppercase=..."
>
> If you want to create a validator without any specific constraint (like
> the required validator which describes itself as a constraint), use Void
> for constraint type:
>
>

--
View this message in context: 
http://www.nabble.com/T5%3A-contributing-a-validator--tp16194294p16198344.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Ce message et les pièces jointes sont confidentiels et réservés à l'usage 
exclusif de ses destinataires. Il peut également être protégé par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant 
être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra 
être recherchée quant au contenu de ce message. Bien que les meilleurs efforts 
soient faits pour maintenir cette transmission exempte de tout virus, 
l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne 
saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for 
the addressee; it may also be privileged. If you receive this e-mail in error, 
please notify the sender immediately and destroy it. As its integrity cannot be 
secured on the Internet, the Atos Origin group liability cannot be triggered 
for the message content. Although the sender endeavours to maintain a computer 
virus-free network, the sender does not warrant that this transmission is 
virus-free and will not be liable for any damages resulting from any virus 
transmitted.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to