Thanks. I'd prefer a custom checkbox class with converter. I just created a
test class as below but not working. Appreciate any pointers.
I did not find an example to follow.
public class CheckBoxYN extends CheckBox{
public CheckBoxYN(String id){
super(id);
}
@Override
public final IConverter getConverter(Class arg0){
IConverter icYN = new IConverter(){
public Object convertToObject(String arg0, Locale arg1) {
if (arg0.equals("true")){
return 'Y';
}else{
return 'N';
}
}
public String convertToString(Object arg0, Locale arg1) {
if(arg0.toString().equals('Y')){
return "true";
}else{
return "false";
}
}
};
return icYN;
}
}
>On Tue, 25 Mar 2008, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]