-Igor
On 4/7/06, Jaime De La Jara <[EMAIL PROTECTED]> wrote:
Here is the original code to define a Date format :
getApplicationSettings().setConverterFactory(new IConverterFactory()
{
public IConverter newConverter(final Locale locale)
{
final Converter converter = new Converter(locale);
// String -> Date
DateConverter dc = new DateConverter();
dc.setDateFormat(locale, new SimpleDateFormat("dd-MM-yyyy"));
converter.set(Date.class, dc);
// Date -> String
DateToStringConverter dsc = new DateToStringConverter();
dsc.setDateFormat(locale, new SimpleDateFormat("dd-MM-yyyy") );
converter.set(String.class, dsc); (*)
return converter;
}
}
);
But in this case a float value gets formatted as it were
a Date.
If a insert the following code in (*) :
// Float -> String
NumberToStringConverter numberToStringConverter = new NumberToStringConverter();
DecimalFormat fmt = new
DecimalFormat("###,###,###,###.#####");
numberToStringConverter.setNumberFormat(locale, fmt);
final StringConverter stringConverter = new StringConverter();
stringConverter.set(Float.class, numberToStringConverter);
stringConverter.set(Float.TYPE, numberToStringConverter);
stringConverter.set(Date.class , dsc);
converter.set(String.class, stringConverter);
converter.set(Float.class, new FloatConverter());
I get the float value correctly formmatted but the date is
displayed using Date.toString().
Jaime.
can you show me youre converter code?On 4/6/06, Jaime De La Jara < [EMAIL PROTECTED]> wrote:
>
> Yes, I use the following code :
>
> add(new TextField("montoTotal", Float.class));
>
> I've made some tests and found that commenting the
> definition of the IConverterFactory for the date format
> and defining the format for the float field and it worked,
> however I cannot define the format for both types.
>
> Thanks,
>
> Jaime.
>
>
>
> did you do TextField.setType(Float.class) or create it with
> the constructor that takes the class?
>
> -Igor
>
>
> On 4/6/06, Jaime De La Jara <[EMAIL PROTECTED]> wrote:
> >
> > Hi, I've just downloaded version 1.2 beta 3 and I have a
> > problem when editing the contents of a javabean,
> > particularly in a case of a Float field. The relevant
> > code is :
> >
> > Javabean :
> > public class Pago
> > {
> > .....
> > public Float getMontoTotal()
> > {
> > return Float.valueOf("1234567890");
> > }
> > .......
> > }
> >
> > Html :
> >
> > <td class="tit">
> > <input wicket:id="montoTotal" type="text" class="normal" size="20"/>
> > </td>
> >
> >
> > When the page is displayed it shows the following :
> > 15-01-1970 in the textfield,
> > this value corresponds to the date equivalent (aprox)
> > to the above number in milisec.
> >
> > The only thing I've done that can be important to this
> > issue is to define a new IConverterFactory to apply the
> > same date format to the whole app.
> >
> > What is going on?
> >
> > Thanks.
> >
> > Jaime.
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.