see abstractcheckboxmodel -igor
On Wed, Sep 24, 2008 at 11:37 AM, Cédric Thiébault <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to use a checkbox to set an enum value on my form object > but I always get a type mismatch error (boolean is not an enum and > vice versa). > > My form object has an enum and I want to display a list of checkboxes > to allow the user to select the value. > I don't want to use a radio because my enum can be null and I can't > unselect my radio group once a radio is selected. > > I tried to extends Checkbox to convert teh boolean to the specified > enum... it works only in one way (to set the enum value) but it does > not work when my enum has a value and the checkbox need to render > itself (the value must be a boolean). > > > public class CheckBoxEnum extends CheckBox { > > private final Enum<?> enumValue; > > public CheckBoxEnum(String id, IModel model, String property, > Enum<?> enumValue) { > super(id, new PropertyModel(model, property)); > this.enumValue = enumValue; > } > > @Override > protected void convertInput() { > String value = getValue(); > if (value != null && BooleanUtils.toBoolean(value)) > setConvertedInput(enumValue); > } > } > > Any ideas ? > > Thanks > > Cedric > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]