Browse Source

Added utility method Binder#asRequired() (#9873)

* Added the possiblity of defining a Field as Required without
setting an error message.

* Added @since to asRequired()

* Add droped paragraphs and see tag for asRequired(String)
tags/8.2.0.alpha3
Stephan Knitelius 6 years ago
parent
commit
afb9d3b6c1
1 changed files with 25 additions and 0 deletions
  1. 25
    0
      server/src/main/java/com/vaadin/data/Binder.java

+ 25
- 0
server/src/main/java/com/vaadin/data/Binder.java View File

@@ -619,6 +619,31 @@ public class Binder<BEAN> implements Serializable {
return asRequired(context -> errorMessage);
}

/**
* Sets the field to be required. This means two things:
* <ol>
* <li>the required indicator will be displayed for this field</li>
* <li>the field value is validated for not being empty, i.e. that the
* field's value is not equal to what {@link HasValue#getEmptyValue()}
* returns</li>
* </ol>
* <p>
* For setting an error message, use {@link #asRequired(String)}.
* <p>
* For localizing the error message, use
* {@link #asRequired(ErrorMessageProvider)}.
*
* @see #asRequired(String)
* @see #asRequired(ErrorMessageProvider)
* @see HasValue#setRequiredIndicatorVisible(boolean)
* @see HasValue#isEmpty()
* @return this binding, for chaining
* @since 8.2
*/
public default BindingBuilder<BEAN, TARGET> asRequired() {
return asRequired(context -> "");
}

/**
* Sets the field to be required. This means two things:
* <ol>

Loading…
Cancel
Save