You need 3 classes for this. 1 class to convert from string to number.
1 class to convert from number to string. and 1 converterfactory with
both classes registered for your number type.

for instance

private static final class IridiumConverterFactory implements IConverterFactory
        {
                public IConverter newConverter(Locale locale)
                {

                        DateFormat dateFormat = new 
SimpleDateFormat("dd-MM-yyyy");
                        Locale nl = new Locale("nl", "NL");
                        DateConverter dateConverter = new DateConverter();
                        dateConverter.setDateFormat(nl, dateFormat);
                        StringConverter stringConverter = new StringConverter();

                        DateToStringConverter dateToStringConverter = new 
DateToStringConverter();
                        dateToStringConverter.setDateFormat(nl, dateFormat);


                        stringConverter.set(java.util.Date.class, 
dateToStringConverter);
                        stringConverter.set(java.sql.Date.class, 
dateToStringConverter);
                        stringConverter.set(java.sql.Timestamp.class, 
dateToStringConverter);

                        DoubleConverter doubleConverter = new DoubleConverter();

                        Converter converter = new Converter(locale);
                        converter.set(java.sql.Timestamp.class, dateConverter);
                        converter.set(java.sql.Date.class, dateConverter);
                        converter.set(java.util.Date.class, dateConverter);
                        converter.set(String.class, stringConverter);
                        converter.set(Double.class, doubleConverter);

                        TimeConverter timeConverter = new TimeConverter();
                        converter.set(Time.class, timeConverter);

                        return converter;
                }
        }

Then set this factory in your application.init() like this
applicationSettings.setConverterFactory(new IridiumConverterFactory());
A good starting point for your string to number converter is either
AbstractDecimalConverter or AbstractNumberConverter.

Maurice

On 7/31/06, Paolo Di Tommaso <[EMAIL PROTECTED]> wrote:
> I need to implement a special numbers formatting in my wicket application.
>
> Basically I have to round number to the first digit and use a blank space as
> thousand separator.
>
> For example instead to display number like '1, 000.33' it is required to
> display (and user will input) '1 000'.
>
> I can do that in Wicket?
>
> Thank for helping.
>
> -- Paolo
>
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to