Form layout Validation error message Displaying

Hi.



i am using form layout and validating the textfiled.but validating error message it should come after the textfield.

[b]
FormLayout form = new FormLayout();
TextField tf2 = new TextField(“Street address”);
tf2.addValidator(new StringLengthValidator(
“The name must be 1-10 letters (input: {0})”,
1, 10, true));
tf2.setIcon(FontAwesome.ROAD);
form.addComponent(tf2);


with horizontalLayout it is coming properly.

HorizontalLayout hlayout = new HorizontalLayout();
TextField text = new TextField();

  hlayout.addComponent(text);
  hlayout.addComponent(message);
  layout.addComponent(hlayout);
    text.addValidator(new IntegerValidator("add integer numbers"));
    text.addListener(new TextChangeListener() {
        
        public void textChange(TextChangeEvent event) {

            String err = "";
           
            text.setCursorPosition(event.getCursorPosition());
            for (Validator v : text.getValidators()) {
                try {
                    
                    v.validate(event.getText());
                    
                } catch (InvalidValueException e) {
                    err += e.getMessage() + " ";
                    text.setValidationVisible(true);
                    text.setInputPrompt("add integer numbers");
                  
                }
            }
            if (err.length() > 0) {
                message.setValue(err);
            } else {
                message.setValue(null);
                text.setValidationVisible(false);
            }
        
            
            
        }
    });

[/b]

Thanks

22607.png