You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Steve Eynon <st...@alienfactory.co.uk> on 2013/01/24 18:26:01 UTC

How to set the translate parameter?

Here's a puzzler...

I've extended AbstractTextField and I want to set the translate
@Parameter from within my subclass. Given this parameter is private in
the superclass, how may I do it?

I went as far as making a mixin to set a bound translate parameter on
setupRender, e.g.

    @BindParameter
    private FieldTranslator<Object> translate;

But that gave this error:

    Failure writing parameter 'translate' of component
    Binding InvariantBinding[default translator, parameter value is read-only.

Due to the defaultTranslate in AbstractTextField being a Binding.

    final Binding defaultTranslate() {...}

Anyone any ideas?

Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to set the translate parameter?

Posted by Steve Eynon <st...@alienfactory.co.uk>.
I got round this by Munky Patching AbstractTextField so that

    final Binding defaultTranslate() {...}

becomes

    protected Binding defaultTranslate() {...}

and overriding it in my subclass:

@Override
protected Binding defaultTranslate() {
    String description = String.format("default translator,
'teacherKey' of %s", resources.getCompleteId());
    return new InvariantBinding(resources.getLocation(),
FieldTranslator.class, description) {
        @Override
        public Object get() {
            return fieldTranslatorSource.createTranslator(resources,
"teacherKey");
        }
    };
}

Is there any reason for the default translate to be package protected
AND final??

is it okay if I make a JIRA asking for it to be protected scope and
non-final? (It's a 9 character change!)

Steve.
--
Steve Eynon
-------------------------------
"If at first you don't succeed,
   so much for skydiving!"



On 25 January 2013 01:26, Steve Eynon <st...@alienfactory.co.uk> wrote:
> Here's a puzzler...
>
> I've extended AbstractTextField and I want to set the translate
> @Parameter from within my subclass. Given this parameter is private in
> the superclass, how may I do it?
>
> I went as far as making a mixin to set a bound translate parameter on
> setupRender, e.g.
>
>     @BindParameter
>     private FieldTranslator<Object> translate;
>
> But that gave this error:
>
>     Failure writing parameter 'translate' of component
>     Binding InvariantBinding[default translator, parameter value is read-only.
>
> Due to the defaultTranslate in AbstractTextField being a Binding.
>
>     final Binding defaultTranslate() {...}
>
> Anyone any ideas?
>
> Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org