You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tony Nelson <tn...@starpoint.com> on 2007/05/01 19:02:18 UTC

Tap 4.1.2 translators/validators

If a TextField has both a translator and validators defined, is the 
input passed from the validators the output of the translators?

I have been trying to get something like this working in 4.1.2 (todays 
snapshot) that worked fine in 4.0.

        <input jwcid="@TextField" value="ognl:percent"
             validators="validators:required,min=1,max=100"
             translator="translator:percentTranslator"
             displayname="Percent Input"/>

My percentTranslator is registering the dojo events necessary to call:

    translatePercentage:function(value) {
        dojo.log.warn("enter translatePercentage");
        if(!value){return 0;}
        var result = parseFloat(value.replace(/%/,''));
        dojo.log.warn("result=" + result);
        return result;
    }

which simply strips any '%' signs out of the input value and returns a 
Float (which is probably unnecessary).

When I submit my test form, I do see the log messages in Firebug as 
expected, and it definitely is returning the value without a % however I 
get a dojo validation popup that states the value is non-number, and 
does not meet the min/max criteria.

Is there any way to find out what value is being passed to min/max?

Thanks in advance for any help.

Tony Nelson



Re: Tap 4.1.2 translators/validators

Posted by Jesse Kuhnert <jk...@gmail.com>.
Your translator may be getting called but I don't think that's how the rest
of the min/max validators are going to use the value. Each one independently
checks the value of the field in question, so if you wanted to translate the
value beforehand you should set the fields value instead of returning it.

The only thing dojo will check in your return is the javascript/c equivalent
of boolean - so really you should be returning true or false .

On 5/1/07, Tony Nelson <tn...@starpoint.com> wrote:
>
> If a TextField has both a translator and validators defined, is the
> input passed from the validators the output of the translators?
>
> I have been trying to get something like this working in 4.1.2 (todays
> snapshot) that worked fine in 4.0.
>
>         <input jwcid="@TextField" value="ognl:percent"
>              validators="validators:required,min=1,max=100"
>              translator="translator:percentTranslator"
>              displayname="Percent Input"/>
>
> My percentTranslator is registering the dojo events necessary to call:
>
>     translatePercentage:function(value) {
>         dojo.log.warn("enter translatePercentage");
>         if(!value){return 0;}
>         var result = parseFloat(value.replace(/%/,''));
>         dojo.log.warn("result=" + result);
>         return result;
>     }
>
> which simply strips any '%' signs out of the input value and returns a
> Float (which is probably unnecessary).
>
> When I submit my test form, I do see the log messages in Firebug as
> expected, and it definitely is returning the value without a % however I
> get a dojo validation popup that states the value is non-number, and
> does not meet the min/max criteria.
>
> Is there any way to find out what value is being passed to min/max?
>
> Thanks in advance for any help.
>
> Tony Nelson
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com