Sorry, AbstractCheckBoxModel. On 4/26/09, Liam Clarke-Hutchinson <[email protected]> wrote: > Wrapping models in models is one of my favourite things about Wicket. > :D That said, the AbstractCheckboxModel in Wicket extensions can be > handy for one-off deviations from normal checkbox behaviour. > > On 4/25/09, mallet <[email protected]> wrote: >> >> Much thanks... works like a charm. >> >> >> igor.vaynberg wrote: >>> >>> class InverseBooleanModel implements imodel<boolean> >>> private final imodel<boolean> delegate; >>> >>> public inversebooleanmodel(imodel<boolean>delegate) { >>> this.delegate=delegate; } >>> public boolean getobject() { >>> return !delegate; >>> } >>> public void setobject(boolean o) { >>> delegate.setobject(!o); >>> } >>> public void detach() { >>> delegate.detach(); >>> } >>> } >>> >>> add(new checkbox("cb", new inversebooleanmodel(model))); >>> >>> -igor >>> >>> On Fri, Apr 24, 2009 at 8:11 AM, Ryan LaHue <[email protected]> >>> wrote: >>>> I'm scratching my head trying to figure out the best way to reverse the >>>> behavior of a checkbox, i.e. display an unchecked box when the model >>>> behind >>>> is true, and a checked box when the model behind is false. I don't >>>> want >>>> to >>>> negate all my domain objects' getters/setters to accomodate this. >>>> >>>> I was going to override the CheckBox.getConverter class to point to an >>>> extension of CheckBoxConverter with an overridden convertToObject >>>> method >>>> and >>>> simply reverse the: >>>> if ("on".equals(value) || "true".equals(value)) >>>> { >>>> return Boolean.TRUE; >>>> } >>>> else >>>> { >>>> return Boolean.FALSE; >>>> } >>>> >>>> Unfortunately the CheckBox.getConverter method is marked final, so this >>>> is >>>> not a possibility. I could override the onComponentTag method but I do >>>> not >>>> think it would be a good idea since there is a lot going on in there. >>>> >>>> Alternatively if there was a simple way to negate the value of the >>>> setter/getter in a PropertyModel I think that would do the trick, i.e. >>>> new CheckBox("checkbox", new PropertyModel(domainObject, "!blue")); >>>> >>>> Any suggestions? >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Reversing-checkbox-behavior-or-negating-a-property-model-expression-tp23218428p23223605.html >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> 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]
