xq.gwt.mvc.model.BooleanPropertyModel Maven / Gradle / Ivy
package xq.gwt.mvc.model;
public class BooleanPropertyModel extends AbstractPropertyModel {
private static final long serialVersionUID = 8226869386470922934L;
private Boolean value;
public Boolean getValue() {
return value;
}
public void setValue(Boolean value) {
Boolean oldValue = this.value;
this.value = value;
setHasError(false);
notifyPropertyChanged(oldValue, value);
}
@Override
public String getText() {
if(getValue() == null)
return null;
return String.valueOf(getValue());
}
@Override
public void setText(String text) throws ConversionException {
setHasError(false);
if((text == null) ||(text.equals(""))){
setValue(null);
return;
}
Boolean boolVal;
try {
boolVal = Boolean.parseBoolean(text);
} catch (Exception e) {
ConversionException ce = new ConversionException(e.getLocalizedMessage());
ce.initCause(e);
setHasError(true);
throw ce;
}
setValue(boolVal);
}
public Object getObjectValue() {
return getValue();
}
public Class getPropertyType() {
return Boolean.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy