if (provider != null) { final Object convertedObject; if (getConverter() instanceof BiDirectionalConverter) { convertedObject = obj; } else { MetaObjectKey key = metaObject.getKey(); convertedObject = provider.getConverter().convert(type, key.toString()); } if (convertedObject.equals(object)) { option.setSelected(true); } }
        public HtmlComponent createComponent(Object object, Class type) {            HtmlMenu menu = new HtmlMenu();                        String defaultOptionTitle = getDefaultTitle();            menu.createDefaultOption(defaultOptionTitle).setSelected(object == null);                        RenderKit kit = RenderKit.getInstance();            Schema schema = kit.findSchema(getEachSchema());                         List<MetaObject> possibleMetaObjects;                        if (hasSavedPossibleMetaObjects()) {                possibleMetaObjects = getPossibleMetaObjects();            } else {                possibleMetaObjects = new ArrayList<MetaObject>();                                for (Object possibility : getPossibleObjects()) {                    possibleMetaObjects.add(MetaObjectFactory.createObject(possibility, schema));                }            }                        for (MetaObject metaObject : possibleMetaObjects) {                Object obj = metaObject.getObject();                HtmlMenuOption option = menu.createOption(null);                if (getConverter() instanceof BiDirectionalConverter) {                    option.setValue(((BiDirectionalConverter) getConverter()).deserialize(obj));                 } else {                    MetaObjectKey key = metaObject.getKey();                    option.setValue(key.toString());                }                if (getEachLayout() == null) {                    option.setText(getObjectLabel(obj));                }                else {                    PresentationContext newContext = getContext().createSubContext(metaObject);                    newContext.setLayout(getEachLayout());                    newContext.setRenderMode(RenderMode.getMode("output"));                                        HtmlComponent component = kit.render(newContext, obj);                                        option.setBody(component);                }                // select the option                if (provider != null) {                    final Object convertedObject;                    if (getConverter() instanceof BiDirectionalConverter) {                        convertedObject = obj;                    } else {                        MetaObjectKey key = metaObject.getKey();                        convertedObject = provider.getConverter().convert(type, key.toString());                                            }                    if (convertedObject.equals(object)) {                        option.setSelected(true);                    }                }                if (obj.equals(object)) {                    option.setSelected(true);                }            }                        if (isSaveOptions()) {                savePossibleMetaObjects(possibleMetaObjects);            }                        Converter converter = getConverter();            menu.setConverter(new OptionConverter(possibleMetaObjects, converter));                        menu.setTargetSlot((MetaSlotKey) getInputContext().getMetaObject().getKey());            return menu;        }