When validation fails I need to display a validation error message in the
ModalWindow. This code is from my validator.

public class MyValidator
    extends AbstractFormValidator
    implements Serializable {

    private final TextField<Integer> textField;

    public MyValidator( TextField<Integer> textField ) {
        this.textField = textField;
    }

    @Override
    public FormComponent<?>[] getDependentFormComponents() {

        return new FormComponent[] { textField };
    }

    @Override
    public void validate( Form<?> form ) {

        Integer value = textField.getConvertedInput();

        if ( !isValidNumber( value.intValue() ) ) {

            error( textField, ""invalid" );
        }
    }

And in my panel I add it to my text field:

        add( new MyFormValidator( textField ) );

However when I run my code and submit the request, I get an NPE when
value.initValue() is called because getConvertedInput() returns null. There
is no value in the textField at this moment. That's why I thought that I
need to possibly attach a behavior to the text field in order to get the
value. 





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Form-not-displaying-messages-correctly-tp4658351p4658365.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to