Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Suggestion: FieldTypes and Validator behavior

    Hi,

    I like the usage of FieldType in DataSourceField of ds.xml files.

    E.g. default behavior is for type="integer" is to add a integer validator.

    I think, it would be a nice behaviour or property,
    to enable a mask-like validator, which automatically changes the typed in value of the user, in the case of integer, disallow entering any characters except integer.
    Showing a validator error, where user needs to manual fix it, will become obsolete.



    public class IntegerTrimmingType extends SimpleType {

    protected static final String NOTHING = "";

    public IntegerTrimmingType() {
    super(CustomGeneralTypes.integerTrimmingType.name(), FieldType.TEXT);

    setEditParser(new SimpleTypeParser() {

    @Override
    public Object parseInput(String value, DataClass field, DataBoundComponent component, Record record) {
    return String.valueOf(value).replaceAll("[^\\d]*", NOTHING);
    }
    });
    }
    }


    What is your opinion?

    #2
    Thanks for posting that, it may be useful to others.

    Comment

    Working...
    X