List of usage examples for com.vaadin.ui AbstractField setErrorHandler
@Override public void setErrorHandler(ErrorHandler errorHandler)
From source file:nz.co.senanque.vaadinsupport.HintsImpl.java
License:Apache License
public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property, final MessageSource messageSource) { ret.setWidth(getWidth());/*from w w w . j a va2 s . c o m*/ ret.setReadThrough(true); ret.setPropertyDataSource(property); ret.setCaption(property.getLabel()); ret.setRequired(property.isRequired()); if (property.isRequired()) { ret.setInvalidCommitted(true); } if (property.isReadOnly()) { ret.setReadOnly(true); } ret.setEnabled(property.isEnabled()); ret.setVisible(property.isVisible()); ret.setImmediate(m_forceImmediate); ret.setLocale(LocaleContextHolder.getLocale()); MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource); ret.setDescription( messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription())); if (property.isNumeric()) { ret.addStyleName("v-textfield-align-right"); } ret.setErrorHandler(new ComponentErrorHandler() { private static final long serialVersionUID = -1393935533100204195L; public boolean handleComponentError(ComponentErrorEvent event) { Throwable t = event.getThrowable(); while (t != null) { if (t instanceof ValidationException) { ret.setComponentError(new UserError(((ValidationException) t).getMessage())); return true; } t = t.getCause(); } return false; } }); }
From source file:nz.co.senanque.vaadinsupport.TouchkitHintsImpl.java
License:Apache License
public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property, final MessageSource messageSource) { ret.setWidth(getWidth());/* w ww.j a va 2s. c o m*/ ret.setReadThrough(true); ret.setPropertyDataSource(property); ret.setCaption(property.getLabel()); ret.setRequired(property.isRequired()); if (property.isRequired()) { ret.setInvalidCommitted(true); } ret.setReadOnly(property.isReadOnly()); ret.setEnabled(property.isEnabled()); ret.setVisible(property.isVisible()); ret.setImmediate(m_forceImmediate); ret.setLocale(LocaleContextHolder.getLocale()); MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource); ret.setDescription( messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription())); if (property.isNumeric()) { ret.addStyleName("v-textfield-align-right"); } ret.setErrorHandler(new ComponentErrorHandler() { private static final long serialVersionUID = -1393935533100204195L; public boolean handleComponentError(ComponentErrorEvent event) { Throwable t = event.getThrowable(); while (t != null) { if (t instanceof ValidationException) { ret.setComponentError(new UserError(((ValidationException) t).getMessage())); return true; } t = t.getCause(); } return false; } }); }