litesoft
@ 632
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / input / fieldsupport / AbstractGeneratedStringInputField.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package com.temp.client.foundation.widget.input.fieldsupport; import com.temp.shared.utils.Validate; import com.temp.shared.validators.MaxLengthValueValidator; public abstract class AbstractGeneratedStringInputField<C extends AbstractGeneratedStringInputField<C>> extends AbstractGeneratedInputField<String, C> { private Integer maxLength; public final Integer getMaxLength() { return maxLength; } public final void setMaxLength(Integer maxLength) { assertBuildMode("setMaxLength"); setValidatedMaxLength(Validate.optionalLength("MaxLength", maxLength)); } public C maxLength(int maxLength) { assertBuildMode("maxLength"); setValidatedMaxLength(Validate.optionalLength("MaxLength", maxLength)); return inheritanceLeaf(); } protected void setValidatedMaxLength(Integer maxLength) { this.maxLength = maxLength; } // The above must be set/changed BEFORE the widget is attached! @Override protected void augmentValidator(InputWidgetValidator<String> validator) { if (maxLength != null) { addTo(validator, new MaxLengthValueValidator(maxLength)); } super.augmentValidator(validator); } } |