They use choice renderers as well as converters. IChoiceRenderer.getDisplayValue returns an Object that gets converted to a string. This is from AbstractChoice in Wicket 1.2:

protected void appendOptionHtml(AppendingStringBuffer buffer, Object choice, int index,
                        String selected)
        {
                final String displayValue = (String)getConverter().convert(
                                renderer.getDisplayValue(choice), String.class);
...


Has this changed in 1.3?

-Ryan


On Aug 13, 2007, at 8:14 AM, Igor Vaynberg wrote:

afik ddcs dont use converters because they use a choice renderer.
see ddc.setchoicerenderer();
-igor


On 8/13/07, Benjamin Ernst <[EMAIL PROTECTED]> wrote:

Hi,

I implemented a custom Converter. It looks like this:

public class AnredeConverter implements IConverter {

    public Object convertToObject(String arg0, Locale arg1) {
        if(arg0 == null) return null;
        return Anrede.fromString(arg0);
    }

    public String convertToString(Object obj, Locale locale) {
            Anrede an = (Anrede) obj;
            return an.getValue();
    }
}


The I added it to the apllication:

@Override
    protected IConverterLocator newConverterLocator() {
        ConverterLocator converterLocator = new ConverterLocator();
        converterLocator.set(Anrede.class, new AnredeConverter());
        return converterLocator;
    }

I use it for a DropDownChoice

DropDownChoice anrede = new DropDownChoice("anrede", new PropertyModel(ma,
"anrede"), Anrede.literals());
add(anrede);

My problem is that the convertToString-Method is never called, so that the DropDownChoice is not set to the right value.The convertToObject- Method
works fine.

How can I tell the DropDownChoice to use the Converter to get the right
value.

Thanks in advance,
Benjamin



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to