List of usage examples for com.vaadin.ui AbstractField setComponentError
public void setComponentError(ErrorMessage componentError)
From source file:de.escidoc.admintool.view.validator.EmptyFieldValidator.java
License:Open Source License
/** * A simple validator to test, if the field is filled. * // w w w. ja v a 2 s. c om * @param field * The field to test. * @param message * The message that should be shown (as a tooltip) if the result is bad. * @return true if the field is filled, otherwise false. */ public static synchronized boolean isValid(final AbstractField field, final String message) { if (!(field.getValue() != null && ((String) field.getValue()).trim().length() > 0)) { field.setComponentError(null); field.setComponentError(new UserError(message)); return false; } field.setComponentError(null); return true; }
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
License:Apache License
public void bind(final MaduraForm form, final AbstractField field, MaduraPropertyWrapper property) { field.setPropertyDataSource(property); Hints hints = getHints();/*w w w. j a va 2 s . c o m*/ hints.setCommonProperties(field, property, m_messageSource); setPermissions(property, field); registerWidget(field); field.addListener(new MaduraPropertyWrapper.ValueChangeListener() { private static final long serialVersionUID = -3295559168401789196L; public void valueChange(ValueChangeEvent event) { com.vaadin.data.Property p = field.getPropertyDataSource(); if (p instanceof MaduraPropertyWrapper) { MaduraPropertyWrapper property = (MaduraPropertyWrapper) p; if (property.getErrorText() != null) { field.setComponentError(new UserError(property.getErrorText())); } else { field.setComponentError(null); } } List<String> errors = new ArrayList<String>(); if (form != null) { for (Object propertyId : form.getItemPropertyIds()) { Field f = form.getField(propertyId); if (f instanceof AbstractField) { AbstractField fieldy = (AbstractField) f; if (fieldy.getComponentError() != null) { errors.add(fieldy.getComponentError().toString()); } } } form.setErrors(errors); } updateOtherFields(field); } }); }
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
License:Apache License
public void register(final AbstractField field) { if (field instanceof Button) { throw new RuntimeException("Attempted to register a button without a Button Painter"); }// w w w .ja va2 s . c o m registerWidget(field); field.addListener(new MaduraPropertyWrapper.ValueChangeListener() { private static final long serialVersionUID = 5542293169155226281L; public void valueChange(ValueChangeEvent event) { com.vaadin.data.Property p = field.getPropertyDataSource(); if (p instanceof MaduraPropertyWrapper) { MaduraPropertyWrapper property = (MaduraPropertyWrapper) p; if (property.getErrorText() != null) { field.setComponentError(new UserError(property.getErrorText())); } else { field.setComponentError(null); } } // List<String> errors = new ArrayList<String>(); // if (form != null) // { // for (Object propertyId : form.getItemPropertyIds()) // { // Field f = form.getField(propertyId); // if (f instanceof AbstractField) // { // AbstractField fieldy = (AbstractField) f; // if (fieldy.getComponentError() != null) // { // errors.add(fieldy.getComponentError() // .toString()); // } // } // } // form.setErrors(errors); // } updateOtherFields(field); } }); }
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());/* w w w.j a v a 2 s. c om*/ 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());//from ww w. ja va 2 s . 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; } }); }
From source file:org.jdal.vaadin.ui.bind.UserErrorProcessor.java
License:Apache License
/** * {@inheritDoc}/*w w w. j a va2 s . co m*/ */ public void processError(Object control, FieldError error) { if (control instanceof AbstractField) { AbstractField<?> f = (AbstractField<?>) control; f.setComponentError(new UserError(StaticMessageSource.getMessage(error))); fieldSet.add(f); } }
From source file:org.jdal.vaadin.ui.bind.UserErrorProcessor.java
License:Apache License
/** * {@inheritDoc}/*from w w w.j av a 2 s .c o m*/ */ public void reset() { for (AbstractField<?> f : fieldSet) f.setComponentError(null); fieldSet.clear(); }