OptionGroup (AbstractSelect) case insenstive

What would be the best way to make an OptionGroup, and I am guessing any control based on AbstractSelect, case insentive when searching for the item? For example and item of “ITEM” would be selected if I supplied the values “Item” or “item” and so forth.

Hi!

It is case-insensitive by default, but if you want to modify it to be case-sensitive you need unfortunately to go through a little effort, since you need to change the filter it uses. Here is an earlier forum-post about the topic:


https://vaadin.com/forum/#!/thread/2748026/2748025

Tested it and the option group is not case insestive by default. It is case senstive.

The link did not provide much help, but thinking it over I decided to try a converter and that worked. Below is the code for the converter that I used.

private Converter caseInsentive = new Converter<String,String>() {

    @Override
    public String convertToModel(String value,
            Class<? extends String> targetType, Locale locale)
            throws com.vaadin.data.util.converter.Converter.ConversionException {
        // TODO Auto-generated method stub
        return value;
    }

    @Override
    public String convertToPresentation(String value,
            Class<? extends String> targetType, Locale locale)
            throws com.vaadin.data.util.converter.Converter.ConversionException {
        // TODO Auto-generated method stub
        return value.toLowerCase();
    }

    @Override
    public Class<String> getModelType() {
        // TODO Auto-generated method stub
        return String.class;
    }

    @Override
    public Class<String> getPresentationType() {
        // TODO Auto-generated method stub
        return String.class;
    }
};

Not ideal as I will have to make sure the items added to the option group are all the same cases.

Just some addtional information incase someone can provide me with a better way to do this.
First I would like it work with all the AbstractSelect controls.
Second the items I will be adding to the controls will either be in a BeanContainer (the most likely case) or be added to the AbstractSelect using the add item method. I will never be using the SQL container.

Thank you
Freddy

For the record, what kind of environment are you running (server and client)?

In development I am running on a Windows 8 machine, with a Tomcat 7 server running the same machine. I am using Java 6 as the base line for the code and Vaadin 7.1.13.

I do not see how that makes much difference in this issue, except for the Vaadin version. I was actually surprised when the first response back that it was case-insesitive, since Java by default is case sensitive.

This issue is actually becoming more of an issue for me. Running into the same problem with combo boxes also.

The main issue is the database that I am connected to is case-insenstive by default, so when I attempt to match items up using string keys, I can get values with mixed matched cases, and that is causing things to not match in the combo boxes.

Thank you
Freddy