Hello,
I am writing a simple stateless form with validation based on annotations in 
Wicket 7.0.0-SNAPSHOT. When the model's field is annotated @NotNull and 
PropertyValidator is added to its form component, the validation error is not 
generated if user's input is empty. It seems to me that the "Required" flag is 
set too late, because while debugging I noticed that isRequired is called at 
least once before PropertyValidator's onConfigure. In the end the component has 
the flag set but without effect. As a workaround I have created descendants of 
CheckBox, TextArea and TextField with isRequired overriden as follows:

    @Override
    public boolean isRequired() {
        if (!isRequiredRecurse) {
            isRequiredRecurse = true;
            configure(); //this should let PropertyValidator call setRequired
            isRequiredRecurse = false;
        }
        return super.isRequired();
    }

This fixes the problem, so it seems I configured everything correctly and also 
@Pattern works fine which leads me to think it's a bug, right? This may be 
related to issue WICKET-5329 "Required" flag initialized too early in 
PropertyValidator, which is the only ticket I found that could have any 
connection to this.

Sorry if this question has been already asked and answered. 

Thanks!
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to