You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dv...@newfoundmarket.com on 2008/03/25 21:38:48 UTC
CheckBox uses true/false but model is Y/N
Hello:
Is there built-in mechanism to auto convert the checkbox model value to be a character set Y/N or Yes/No or any other pairs?
This is frequently used pattern.
Thanks.
Re: CheckBox uses true/false but model is Y/N
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Tue, 25 Mar 2008, Igor Vaynberg wrote:
> you forgot the important detach() { room.detach(); }
Oops, good catch.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: CheckBox uses true/false but model is Y/N
Posted by Igor Vaynberg <ig...@gmail.com>.
you forgot the important detach() { room.detach(); }
-igor
On Tue, Mar 25, 2008 at 1:52 PM, Timo Rantalaiho <Ti...@ri.fi> wrote:
>
> On Tue, 25 Mar 2008, dvd@newfoundmarket.com wrote:
> > Is there built-in mechanism to auto convert the checkbox model value
> > to be a character set Y/N or Yes/No or any other pairs?
> > This is frequently used pattern.
>
> Probably you could set your own IConverter on the component
> corresponding the checkbox. The converter can then be reused
> as needed.
>
> I've typically (if not always) used checkboxes with custom models
> directly toggling things in domain objects, e.g.
>
> class RoomReservedModel extends Model {
> private IModel room;
>
> public RoomReservedModel(IModel room) {
> this.room = room;
> }
>
> @Override
> public void setObject(Object object) {
> room().setReserved((Boolean) object);
> }
>
> @Override
> public Object getObject() {
> return room().isReserved();
> }
>
> private Room room() {
> return (Room) room.getObject();
> }
> }
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: CheckBox uses true/false but model is Y/N
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Tue, 25 Mar 2008, dvd@newfoundmarket.com wrote:
> Is there built-in mechanism to auto convert the checkbox model value
> to be a character set Y/N or Yes/No or any other pairs?
> This is frequently used pattern.
Probably you could set your own IConverter on the component
corresponding the checkbox. The converter can then be reused
as needed.
I've typically (if not always) used checkboxes with custom models
directly toggling things in domain objects, e.g.
class RoomReservedModel extends Model {
private IModel room;
public RoomReservedModel(IModel room) {
this.room = room;
}
@Override
public void setObject(Object object) {
room().setReserved((Boolean) object);
}
@Override
public Object getObject() {
return room().isReserved();
}
private Room room() {
return (Room) room.getObject();
}
}
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org