HTML in Error Validation

Hey,

is it possible to use HTML in the ErrorBox?

Thanks

Is it correct to Overwrite getHtmlMessage?

If this is right anyone has an example?

Thx a lot.

I have never tried it, but this is exactly how it says in the API docs:

Source:
https://vaadin.com/api/com/vaadin/data/Validator.InvalidValueException.html

Ok i have test it i here so it works:


@SuppressWarnings("serial")
public class InvalidValueExceptionHTML extends InvalidValueException {
	public InvalidValueExceptionHTML(String message) {
		super(message);
	}

	@Override
	public String getHtmlMessage() {
		String s = super.getHtmlMessage();
		return "<b>" + s + "</b>";
	}
}

@SuppressWarnings("serial")
public class IntegerMaxValidator extends AbstractValidator implements Validator {

	private int max;
	private String eString;

	public IntegerMaxValidator(String errorMessage, int max) {
		super(errorMessage);
		this.eString = errorMessage;
		this.max = max;
	}

	@Override
	public boolean isValid(Object value) {

		try {
			int a = Integer.parseInt(value.toString());
			if (a < max) {
				return true;
			}
		} catch (Exception e) {
			System.out.println(e.getStackTrace());
			return false;
		}
		IntegerMaxValidator.this.setErrorMessage(eString);
		return false;
	}

	public void validate(Object value) throws InvalidValueException {
		if (!isValid(value)) {
			String message = getErrorMessage().replace("{0}", String.valueOf(value));
			throw new InvalidValueExceptionHTML(message);
		}
	}

}

know you can call IntegerMaxValidator(“

MeineError Message

”, 128);
and you become and html parsed Error message.

Thx