Exclamation mark does not appear on required fields

Hi,
I have problems to display the error exclamation mark on required fields.
(or maybe I misunderstood the handling)
Here my simple source code:[code]
TextField firstName = new TextField(“First Name:”);
TextField lastName = new TextField(“Last Name:”);

@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

firstName.setRequired(true);
firstName.setRequiredError(“Please enter First Name”);
firstName.setImmediate(true);

lastName.setRequired(true);
lastName.setRequiredError(“Please enter Last Name”);
lastName.setImmediate(true);

Button button = new Button(“Click Me”);
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
try {
firstName.validate();
lastName.validate();
} catch (InvalidValueException e) {
Notification.show("Error: " + e.getMessage());
return;
}
}
});

layout.addComponent(button);
layout.addComponent(firstName);
layout.addComponent(lastName);

}
[/code]The error indicator (exclamation mark) for the required textfields is not displayed (neither if focus leaves the field nor after the validation on button-click ).
How can I handle it to show the exclamation mark when focus leaves the field? After button-click I think with the setCompositionError-Method. Right?

Thanks in advance.

Regards
Gerhard

I could of course be wrong, but if the component’s validation fails, it should show the exclamation mark.

VerticalLayout layout = new VerticalLayout();

TextField firstName = new TextField("First Name:");
firstName.setImmediate(true);
firstName.addValidator(new Validator() {
  @Override
  public void validate(Object value) throws InvalidValueException {
    if (value.toString().length() < 5) {
      throw new InvalidValueException("Lorem Ipsum");
    }
  }
});

layout.addComponents(firstName);

Hello Joacim,
thanks very much for your answer and sorry for my late response.
I think if you set the textfield as required, then the error indicator (exlamation mark) is not displayed.

firstName.setRequired(true) It looks a little bit strange for me, that no error indicator is displayed, anyway it’s no longer a problem for me.

Thanks
Gerhard

Hey Gerhard,

I tried the following piece of code, and I had no issues with the exclamation mark missing upon validation failure. Glad to hear you solved it, though.
[code]
VerticalLayout layout = new VerticalLayout();
setContent(layout);

TextField firstName = new TextField(“First Name:”);
firstName.setImmediate(true);
firstName.setRequired(true);
firstName.addValidator(new Validator() {
@Override
public void validate(Object value) throws InvalidValueException {
if (value.toString().length() < 5) {
throw new InvalidValueException(“Lorem Ipsum”);
}
}
});

layout.addComponents(firstName);
[/code]