required error message not shown

hi all, I have an issue with the setrequired() method for fields.
I have set a few fields to be required and when the user hits save and the required fields are not given, the save button simply doesn’t work and there is no error message (like the Red circle exclamation mark I have for another custom validator I wrote). Any ideas why this might be? I have set thesetRequiredError(“Field is required.”) also.

Can you show some code or better an app that reproduce the issue? What does your save button do?

the save button does nothing, when followed in debug I realise that that validation itself fails when there is no input in the required field (expected), the required fields themselves have the * (asterisk) it literally is just that the required validation message is not generated. Here is the code I have used:

[code]

TextField tf = ((TextField) field);
tf.setRequired(true);
tf.setNullRepresentation(“”);
tf.setRequiredError(“Field is required.”);
tf.setImmediate(true);
tf.setValidationVisible(true);
[/code]

Validation is only done when you call validate() or commit() for the field or for the containing form.

yeah thanks, which is when the save button is pressed in this instance. I have a check in the save event handler code, if (!isvalid()) { return; } else commit();

Wait I am confused. First you say that your save button does nothing and in the next reply it uses some flags. Showing the complete code would help here.

Call commit(). It will validate first and throw an appropriate exception if validation fails

Ah yes, isValid() just checks that the fields are valid. The commit() also sets setValidationVisible(true). If you call just isValid(), you need to set that manually.

The normal way to handle commit is:

    public void buttonClick(ClickEvent event) {
        try {
            form.commit();
        } catch (EmptyValueException e) {
            // A required value was missing
        }
    }