I believe you're correct, that the built-in translators do not take an
expression there.  There was a posting a couple of weeks ago about a
related thing, using an expression in a date validator.  One solution
was to use an expression in a bean specification and use that as the
validator.

    <bean name="maxDate1"
class="org.apache.tapestry.form.validator.MaxDate">
      <set name="maxDate" value="new java.util.Date()"/>
    </bean>

    <component id="inputLastPasswordDate" type="TextField">
        <binding name="value" value="employee.hireDate"/>
        <binding name="translator" value="translator:date"/>
        <binding name="validators" value="validators:$maxDate1"/>
    </component>

I tried the same idea on a translator.  This doesn't work:

    <component id="startDatePicker" type="DatePicker">
        <binding name="translator"
value="translator:date,pattern=ognl:datePattern"/>

but this does:

    <bean name="dateTranslator1"
class="org.apache.tapestry.form.translator.DateTranslator">
        <set name="pattern" value="ognl:datePattern"/>
    </bean>

    <component id="startDatePicker" type="DatePicker">
        <binding name="translator" value="bean:dateTranslator1"/>


I tested it with a toy method getDatePattern() that returned a
randomized choice from two patterns.

I arrived at that after some googling and trial and error.  I expected
the last line to have a syntax more like the validator's, like: 
value="translator:$dateTranslator1".  Someone might point out a better way.



Leonardo Quijano Vincenzi wrote:

> Is there any way to specify dynamic translators, that depend on some
> OGNL expression??
>
> Something like this:
>
> <input jwcid="[EMAIL PROTECTED]"
>          translator="translator:number,pattern=SomeOGNLExpression"
>          value="ognl:someNumber" />
>
> ???
>
> I've been looking around but I didn't found a way to inject the
> translator in the page class or something similar.
> Ideas?
>


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

Reply via email to