Instead of going to the extent of overriding a class because your model
value is not updated, why not fix the problem?

Take a look at the component reference wicket-example project:
http://www.wicket-library.com/wicket-examples/compref/

More precisely at the DropDownChoice:
http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/or
g.apache.wicket.examples.compref.DropDownChoicePage?0

-----Original Message-----
From: Lawrence, Sean [mailto:sean.lawre...@mantech.com] 
Sent: Wednesday, August 01, 2012 7:19 PM
To: users@wicket.apache.org
Subject: Boolean DropDownChoice

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.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to