You can dynamically create translator:
@Inject
private FieldTranslatorSource fieldTranslatorSource;
public getMyTranslator() {
switch(myAccountType) {
case ACCOUNT_TYPE1:
return createTranslator("myField", "myTranslator1");
// other types
}
return null;
}
protected FieldTranslator createTranslator(final String componentId, final
String translator) {
final ComponentResources componentResources =
resources.getEmbeddedComponent(componentId).getComponentResources();
return fieldTranslatorSource.createTranslator(componentResources,
translator);
}
In this example account type should be populated before account number. So
if select is placed after textfield it will result with incorect behaviour.
To fix this I usually use trick with FormFragment component:
<t:formfragment visible="true">
<t:textfield .../>
</t:formfragment/>
<t:select .../>
On Mon, Jul 8, 2013 at 11:56 AM, Nathan Quirynen <
[email protected]> wrote:
> Hi,
>
> In multiple forms I have a textfield containing a bank account number and
> next to it a select component containing the account number type (enum).
> Now I want to add a translator for the textfield, to automaticaly format
> the value, but the formatting is different for each account number type. I
> now have a translator for each type, but it would be nice if i could make
> just 1 and somehow pass the type. Is there a way to do this?
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>
--
BR
Ivan