You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mw...@kcp.com on 2012/04/09 15:20:27 UTC
translate problem
I am writing a new component and this is first time I have needed to use
the Translate parameter.
I am using version 5.3.1
I am getting this error : Failure reading parameter 'translate' of
component InfoTest:namesearch.name: Unknown translator type 'translator'.
I know my code it incomplete and probably has errors in it, but I can't get
past this error that I don't understand.
Any help would be appreciated.
tml file
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
>
<t:textfield t:id="name" value="luser" translate="translator"
t:mixins="autocomplete"></t:textfield>
</t:container>
jave file
package hmits.components;
import java.util.ArrayList;
import java.util.List;
import hmits.business.LdapUser;
import org.apache.tapestry5.FieldTranslator;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ValidationException;
import org.apache.tapestry5.annotations.Parameter;
public class NameSearch
{
@Parameter(required = true )
private LdapUser luser;
public List<LdapUser> onProvideCompletionsFromName(String partial)
{
LdapUser lu;
List<LdapUser> result = new ArrayList<LdapUser>();
lu = new LdapUser();
lu.setName("name1");
lu.setId("00001");
result.add(lu);
lu = new LdapUser();
lu.setName("name2");
lu.setId("00002");
result.add(lu);
return result;
}
public LdapUser getLuser()
{
return luser;
}
public void setLuser(LdapUser luser)
{
this.luser = luser;
}
public FieldTranslator<LdapUser> getTranslator()
{
return new FieldTranslator<LdapUser>()
{
public String toClient(LdapUser value)
{
String clientValue = "";
if (value != null)
clientValue = String.valueOf(value.getName
());
return clientValue;
}
public Class<LdapUser> getType() { return LdapUser.class
; }
public LdapUser parse(String clientValue) throws
ValidationException
{
LdapUser serverValue = new LdapUser();
if (clientValue != null && clientValue.length() >
0 )
serverValue.setName(clientValue);
return serverValue;
}
public void render(MarkupWriter arg0)
{
}
};
}
}
Michael Williamson
Analyst Sr Applications Developer
Phone: 816/997-5994
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: translate problem
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hi!
On Mon, 09 Apr 2012 10:20:27 -0300, <mw...@kcp.com> wrote:
> I am writing a new component and this is first time I have needed to use
> the Translate parameter.
>
> I am getting this error : Failure reading parameter 'translate' of
> component InfoTest:namesearch.name: Unknown translator type 'translator'.
You should contribute your translator to the TranslatorSource service.
Something like this in your AppModule:
public static void contributeTranslatorSource(Configuration<Translator>
configuration) {
configuration.add(new YourTranslator()) {
}
This has the advantage of being your translator being used automatically
used when it fits.
Another option is to use translate="prop:translator" instead of
translate="translator", as the translate parameter default binding is
'translate', not 'prop'.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org