PDA

View Full Version : Restriction Non allowing zero and empty values in NumberField



praveenmj
21 Feb 2012, 4:21 AM
Hi Guys,

I have a requirement in NumberField. my NumberField should not allow Zero or empty value.and it should populate the Minimum Value which i set. how it can be done .... any ideas?

Thanks and your ideas are welcome

MJP

Ersmarker
22 Feb 2012, 4:27 AM
int minValue = 3;
NumberField nf = new NumberField();
nf.setAllowBlank(false);
nf.setMinValue(minValue);
nf.setValue(minValue);

praveenmj
22 Feb 2012, 5:49 AM
Hi Ersmarker ,

Thanks for the reply , i used the above code ,but in the UI it allows zero and just shows the error tooltip. In My case i have to stop the user from entering zero or empty value ... for example by keeping http://www.selikoff.net/2011/04/26/gwt-bounded-textfield-in-gxt/ it as reference i have created but not working could yo please help me on this Thanks....


public class BoundedNumberField extends NumberField {

@Override
public void setMinValue(Number minValue) {
// TODO Auto-generated method stub
super.setMinValue(minValue);
if(rendered){

getInputEl().setValue(String.valueOf(minValue.intValue()));
}

//setElementAttribute("minValue", minValue.intValue());

}
@Override
protected void onRender(Element target, int index) {
super.onRender(target, index);
getInputEl().setElementAttribute("minValue", getMinValue().intValue());

}

}