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 2007/11/03 20:20:47 UTC
T5.0.6 : How to format a number in a TextField
In Tap 4, I can use translator:number,pattern=0.#
(which used NumberTranslator.java)
to format the numeric value in a TextField component.
How can this be done in T5.0.6 ?
I have checked the T5.0.6 API, it looks as though
T5.0.6 has no
NumberTranslator.java .
Must I implement a NumberTranslator ?
Shing
Home page : http://www.lombok.demon.co.uk/
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5.0.6 : How to format a number in a TextField
Posted by Marcus <mv...@gmail.com>.
Sorry, this is to output, not used in Textfield
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5.0.6 : How to format a number in a TextField
Posted by Marcus <mv...@gmail.com>.
Hi Shing,
Try this http://wiki.apache.org/tapestry/Tapestry5OutputLocaleNumber
Marcus
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5.0.6 : How to format a number in a TextField
Posted by Shing Hing Man <ma...@yahoo.com>.
I have extended DoubleTranslator.java and
override the method DoubleTranslator.toClient to
format the output.
public class MyDoubleTranslator extends
DoubleTranslator{
@Override
public String toClient(Double value) {
String returnValue = null;
DecimalFormat formatter = new DecimalFormat("0.#");
if (value==null){
returnValue = "";
}
else{
returnValue = formatter.format(value);
}
return returnValue;
}
}
In AppModule, I added
public static void contributeTranslatorSource(
MappedConfiguration<String, Translator>
configuration)
{
configuration.add("myDouble", new
MyDoubleTranslator());
}
Now I just add translate="translate:myDouble"
to <t:textField> to have the displayed number
formatted . The above works. But the format pattern
"#.0" is
hard coded.
Is there anyway to do something like
translate="translate:myDouble,pattern=#.0" ?
Thanks in advance for any assistance!
Shing
--- Shing Hing Man <ma...@yahoo.com> wrote:
> In Tap 4, I can use translator:number,pattern=0.#
> (which used NumberTranslator.java)
> to format the numeric value in a TextField
> component.
>
> How can this be done in T5.0.6 ?
>
> I have checked the T5.0.6 API, it looks as though
> T5.0.6 has no
> NumberTranslator.java .
>
> Must I implement a NumberTranslator ?
>
> Shing
>
> Home page : http://www.lombok.demon.co.uk/
>
>
>
>
>
___________________________________________________________
>
> Want ideas for reducing your carbon footprint? Visit
> Yahoo! For Good
>
http://uk.promotions.yahoo.com/forgood/environment.html
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail:
> users-help@tapestry.apache.org
>
>
Home page : http://www.lombok.demon.co.uk/
___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org