[ 
https://issues.apache.org/jira/browse/WICKET-530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Igor Vaynberg resolved WICKET-530.
----------------------------------

    Resolution: Won't Fix
      Assignee: Igor Vaynberg

all you have to do is override getconverter() and return the appropriate one, so

add(new textfield("value") { iconverter getconverter() { return new 
MyTwoDecimalPointDoubleConverter(); }

>PS: Why FormComponent.type is Class? I think Object or String will be better. 
>This gives >more freedom for ConverterLocator. In my project I have about 4 
>converters for Double >which uses four different DecimalFormats for 
>convert/parse values. Why do I need >create four classes for it? With String 
>type selector I can be use four instances of one >DecimalFormatConverter each 
>of them is initialized with customized DecimalFormat >instance.

because type is safer and refactorable, lets say you wanted to make a textfield 
for integers..
add(new textfield("age", Integer.class) makes sense, where as
add(new textfield("age", "wicket.integer") doesnt because that is a magic 
string that the user has to dig up from somewhere. besides this is type 
conversion - where you convert between a String and some other Class so it 
makes sense.

> FormComponent.type ignored for print
> ------------------------------------
>
>                 Key: WICKET-530
>                 URL: https://issues.apache.org/jira/browse/WICKET-530
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta1
>         Environment: jdk1.4 wicket-1.3.-incubating-beta1
>            Reporter: Ivlev Dmitry
>            Assignee: Igor Vaynberg
>             Fix For: 1.3.0-rc1
>
>
> I have created text field:
> add(new TextField("quantity", Converters.QUANTITY.getClass()));
> and register my custom converter in session's ConverterLocator.
> But my converter is not called for markup output because:
> TextField.onComponentTag => tag.put("value", getValue());
> FormComponent.getValue => return getModelValue();
> FormComponent.getModelValue => return getModelObjectAsString();
> Component.getModelObjectAsString() =>
>               final Object modelObject = getModelObject();
>               if (modelObject != null)
>               {
>                       // Get converter
>                       final IConverter converter = 
> getConverter(modelObject.getClass());
> As a result FormComponent.type is ignored and I need to overwrite  method 
> getConverter for right converter selection.
> PS: Why FormComponent.type is Class? I think Object or String will be better. 
> This gives more freedom for ConverterLocator. In my project I have about 4 
> converters for Double which uses four different DecimalFormats for 
> convert/parse values. Why do I need create four classes for it? With String 
> type selector I can be use four instances of one DecimalFormatConverter each 
> of them is initialized with customized DecimalFormat instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to