Hi,

I'm trying to create a custom form component that extends a 
DropDownChoice<Boolean>. The reason I'm doing this is because I need a form 
component that forces a user to select a choice. However, I'm unable to get the 
model to update. What am I not overriding properly? I'm all ears for 
suggestions if there is a better way to do this as well.

/**
* A Boolean form component that uses a drop down choice so that
* a user is forced to choose between "Yes" or "No".
*
*/
public class YesNoDropDownChoice extends DropDownChoice<Boolean> {

      private static final long serialVersionUID = 1L;

      public YesNoDropDownChoice(String id, IModel<Boolean> model) {
            super(id, model, Arrays.asList(
                        Choice.YES.getBoolean(),
                        Choice.NO.getBoolean()));
            onModelChanged();
      }

      @Override
      protected void onModelChanged() {
            super.onModelChanged();
            setModelObject(getModelObject());
      }

      /**
      * {@inheritDoc}
      */
      @Override
      protected void convertInput() {
            Boolean b = getModelObject();
            setConvertedInput(b);
      }
}

Thanks in advance,

Sean Lawrence


________________________________
This e-mail and any attachments are intended only for the use of the 
addressee(s) named herein and may contain proprietary information. If you are 
not the intended recipient of this e-mail or believe that you received this 
email in error, please take immediate action to notify the sender of the 
apparent error by reply e-mail; permanently delete the e-mail and any 
attachments from your computer; and do not disseminate, distribute, use, or 
copy this message and any attachments.

Reply via email to