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

Reply via email to