2
votes

I used to add validator constraints on TextFields and TextArea but it now throws java.lang.IllegalArgumentException: addConstraint needs an InputComponent as first argument.

    Form hi = new Form("Welcome", new TextModeLayout(3, 2));
    Validator validator = new Validator();
    TextField txt = new TextField();

    validator.addConstraint(txt, new LengthConstraint(1, "HI"));

    Button btnVal = new Button("VALIDATE");
    validator.addSubmitButtons(btnVal);

    hi.add(txt);
    hi.add(btnVal);
    hi.show();

Replacing the Textfield with a TextComponent works. So is that a regression or is that intended and why ?

1

1 Answers

2
votes

That's a regression due to this PR https://github.com/codenameone/CodenameOne/pull/2475

I've fixed it and we might push a hot fix on Thursday to resolve it.