You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by resign <se...@yahoo.de> on 2012/01/23 11:32:05 UTC

Use Translator

hello,

i try to use Translator to translate some values:

Following was made:
1. class EmailOfContactTranslator was created and added to configuration in
AppModule


When i debug my app i see that  toClient method is called and works fine.

But 
parseClient(Field field, String value, String message)

seems not to be called.

By the way, is it possible to get informal parameters from Field in the
method parseClient?

greeting
resign




--
View this message in context: http://tapestry.1045711.n5.nabble.com/Use-Translator-tp5165694p5165694.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


Re: Use Translator

Posted by resign <se...@yahoo.de>.
hi,
i want to say "THANKS" for help.

Unfortunately it was not possible to get this thing to run, so i made an
work around.
It now works, the problem was - 
no communication between developers



bye

Live long and prosper!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Use-Translator-tp5165694p5429751.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


Re: Use Translator

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 23 Jan 2012 11:06:48 -0200, resign <se...@yahoo.de> wrote:

> thanks,
>
> i get an Exception
> org.apache.tapestry5.ioc.util.UnknownValueException: Could not find a
> coercion from type java.lang.String to type ...Email
> Do i need an own TypeCoercer ?

You'll need the translate parameter.

-- 
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


Re: Use Translator

Posted by resign <se...@yahoo.de>.
thanks,

i get an Exception 
org.apache.tapestry5.ioc.util.UnknownValueException: Could not find a
coercion from type java.lang.String to type ...Email


Do i need an own TypeCoercer ?

greetings,
resign

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Use-Translator-tp5165694p5166021.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


Re: Use Translator

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 23 Jan 2012 09:08:59 -0200, resign <se...@yahoo.de> wrote:

> Wow
> very quick answer :-)

This mailing list is known for quick answers. :)

>
> Snip of my AppModule
> ------------
>   public static void
>             contributeTranslatorSource(MappedConfiguration<Class, Object>
> configuration){
>         configuration.add(Email.class, new EmailOfContactTranslator());
>     }

Looks ok.

> ------------
>
> Snip of Translator
> ----------------------
>  public class EmailOfContactTranslator implements Translator{
>   ....
>     @Override
>     public Email
>             parseClient(Field field, String value, String message) throws
> ValidationException{
>         return new Email(value);
>     }

Looks ok.

> And TML-File
> -----------------------
> <t:ajaxFormLoop id="emails" source="contactCommunication5"
> value="currentMail">
>   <t:submitNotifier>
>      <t:textField value="currentMail"
> 	validate="email" style="width: 294px;"
> 	clientId="${contact.smdId}"
> 	translator="emailOfContactTranslator"

The parameter is "translate", not "translator". Make sure the currentMail  
property is of type Email. In addition, TextField figures out the correct  
translator for the field based on the edited property class, so you  
shouldn't even need to set the translate parameter.

-- 
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


Re: Use Translator

Posted by resign <se...@yahoo.de>.
Wow
very quick answer :-)

Snip of my AppModule
------------
  public static void
            contributeTranslatorSource(MappedConfiguration<Class, Object>
configuration){
        configuration.add(Email.class, new EmailOfContactTranslator());
    }
------------

Snip of Translator
----------------------
 public class EmailOfContactTranslator implements Translator{
  ....
    @Override
    public Email
            parseClient(Field field, String value, String message) throws
ValidationException{
        return new Email(value);
    }
...
-----------------------

And TML-File
-----------------------
<t:ajaxFormLoop id="emails" source="contactCommunication5"
value="currentMail">
  <t:submitNotifier>
     <t:textField value="currentMail" 
	validate="email" style="width: 294px;" 
	clientId="${contact.smdId}"
	translator="emailOfContactTranslator"
     />
    <t:removeRowLink>remove</t:removeRowLink>
  </t:submitNotifier>
  <t:parameter name="addRow">
     <t:addRowLink>add</t:addRowLink>
  </t:parameter>
</t:ajaxFormLoop>
--------------------------------



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Use-Translator-tp5165694p5165791.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


Re: Use Translator

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 23 Jan 2012 08:32:05 -0200, resign <se...@yahoo.de> wrote:

> hello,

Hi!

>
> i try to use Translator to translate some values:
>
> Following was made:
> 1. class EmailOfContactTranslator was created and added to configuration  
> in AppModule
>
>
> When i debug my app i see that  toClient method is called and works fine.
>
> But
> parseClient(Field field, String value, String message)
>
> seems not to be called.

Please post your template and Java code.

> By the way, is it possible to get informal parameters from Field in the
> method parseClient?

No.

-- 
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