Multi select for OptionGroup

Hi,

I have use an OptionGroup to display an option of. Then I use to setMultiSelect(true) for this component.
How to display multi selected option?

I have this code in my application:

        OptionGroup optionGroup = new OptionGroup();
        BeanItemContainer<Entity> container = new BeanItemContainer<Entity>(Entity.class, list);
        optionGroup.setContainerDataSource(container);
        optionGroup.setItemCaptionPropertyId("propertyName");
        optionGroup.setMultiSelect(true);

So I have a list of checkbox list display in browser, then how to set selected multi checkbox by default?

Thanks.

I found the solution. I can use the setValue method.


        OptionGroup optionGroup = new OptionGroup();
        BeanItemContainer<Entity> container = new BeanItemContainer<Entity>(Entity.class, list);
        optionGroup.setContainerDataSource(container);
        optionGroup.setItemCaptionPropertyId("propertyName");
        optionGroup.setMultiSelect(true);

        optionGroup.setValue(listOfSelectedEntity);


reference