You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shing Hing Man <ma...@yahoo.com> on 2006/06/28 15:58:32 UTC

Custom translator for a List

I am trying to write a custom translator to  convert a
List<Number>
to a comma seperated list of numbers, to be displayed
in a 
component TextArea. (And during form submit, the  
comma seperated list of numbers
is converted to a List<Number> by the custom
translator.)

So I extend  AbstractTranslator and called my
translator DataTranslator.
To use it, I would have  the following in my .page :


 <component id="dataTA" type="TextArea">
        <binding name="value" 
value="ognl:myNumbers"/>        
        <binding name="displayName"
value="literal:Data"/> 	   	            
        <binding name="translator"
value="translator:dataTranslator"/>
    </component>

where 
   myNumbers is a property of type List<Number>,
   and the class  behind dataTranslator is
DataTranslator, 
   a subclass of AbstractTranslator.

In the method ,
DataTranslator.formatObject(IFormComponent field,
Locale locale,
Object object) , where the converstion of List<Number>
to a
comma seperated list of numbers is done, 
I am expecting the type of  object to be List<Number>.
Instead,
it is of type String and looks like "[23,33,234]".

Thanks in advance for any assistance!

Shing



Home page :
  http://uk.geocities.com/matmsh/index.html


		
___________________________________________________________ 
All New Yahoo! Mail – Tired of Vi@gr@! come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html

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