You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rolandpeng <ro...@cht.com.tw> on 2011/01/26 15:59:45 UTC
Re: Use Byte for CheckBox instead of Boolean
Hi, this is YesNoCheckBox referred from previous posts. You can modify to fit
your need.
Roland.
--
public class YesNoCheckBox extends CheckBox {
public YesNoCheckBox(String id) {
super(id);
}
@Override
protected IModel initModel() {
return new CheckBoxYesNoModel(super.initModel());
}
private class CheckBoxYesNoModel implements IModel {
final IModel model;
public CheckBoxYesNoModel(IModel model) {
this.model = model;
}
public void detach() {
model.detach();
}
public Object getObject() {
return convertToComponent(model.getObject());
}
public void setObject(Object object) {
model.setObject(convertFromComponent(object));
}
protected Object convertToComponent(Object o) {
if (o.toString().equalsIgnoreCase("y"))
return true;
else
return false;
}
protected Object convertFromComponent(Object o) {
if (((Boolean) o) == true)
return "y";
else
return "n";
}
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-for-CheckBox-instead-of-Boolean-tp3236065p3238209.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte for CheckBox instead of Boolean
Posted by MattyDE <uf...@gmail.com>.
@ rolandpeng: Thanks alot. It works great!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-for-CheckBox-instead-of-Boolean-tp3236065p3248333.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org