You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2012/05/10 06:34:30 UTC
String translator for components?
Hi all,
I am having a class which acts like a holder for the ajaxforloop row. It is
a generic class which accepts an Object that has values for the row.
Something like this
public class ItemSingleHolder<T> extends ItemHolder {
private T value;
public ItemSingleHolder(Long key, T value ) {
super(key);
this.value = value;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
}
Now if T that I give it is a complex Object (not just a String) then when I
do something like this inside a ajaxformloop
<t:textfield value="currentRow.value.name"/>
where currentRow.value gets the Object that is give for T. And this all
works great.
However if I put String in T I get an exception that says that I am missing
a translator. So I have create a translator which is really simple
public class StringTranslator implements FieldTranslator<String> {
@Override
public Class getType() {
return Object.class;
}
@Override
public String parse(String string) throws ValidationException {
return string;
}
@Override
public String toClient(String t) {
return t.toString();
}
@Override
public void render(MarkupWriter writer) {
}
}
and then when I do this
<t:textfield value="currentRow.value.name" t:translate="string"/>
it works. Any idea why and what is the problem whit all of this? It is
strange that I need this,right?
Cheers
--
View this message in context: http://tapestry.1045711.n5.nabble.com/String-translator-for-components-tp5699116.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org