When the bean generator creates a gettor and settor for an
Editable ComboBox, by default it returns a String on the settor and
takes a string parameter on the gettor. It can be useful to change
the settor to take an Object class and the gettor to return an
Object type. This allows you to determine the user selection using
ChoiceDescriptors.
If a type of Object is detected for the gettor and settor, the
system will expect either a ChoiceDescriptor or a type Object
instead of a formatted string.
Assume that Editable is an editable ComboBox which has either a Double value, uses a system value, or is not set.
public Object getEditable() { if (m_setting == SYSTEMVALUE) { return new ChoiceDescriptor("choice1","System Value"); } else if (m_setting == NOTSET) { return new ChoiceDescriptor("choice2","Value not set"); } else { return m_doubleValue; } }
Similarly, when a type of Object is detected for the gettor and settor, the system will return an Object which is either a ChoiceDescriptor containing the selected choice or a type Object.
public void setEditable(Object item) { if (ChoiceDescriptor.class.isAssignableForm(obj.getClass())) { if (((ChoiceDescriptor)obj).getName().equalsIgnoreCase("choice1")) m_setting = SYSTEMVALUE; else m_setting = NOTSET; } else if (Double.class.isAssignableFrom(obj.getClass())) { m_setting = VALUE; m_doubleValue = (Double)obj; } else { /* error processing */ } }