diff options
author | Stephan Knitelius <stephan@knitelius.com> | 2017-10-20 10:53:45 +0200 |
---|---|---|
committer | Péter Török <31210544+torok-peter@users.noreply.github.com> | 2017-10-20 11:53:45 +0300 |
commit | afb9d3b6c1d143b59506e08c3f27eb088555801c (patch) | |
tree | 68001385df44b773285099035a9ba9ca420fe884 /server | |
parent | 69ac68e064efb91ab21cf5aa4fd7533ae07b6089 (diff) | |
download | vaadin-framework-afb9d3b6c1d143b59506e08c3f27eb088555801c.tar.gz vaadin-framework-afb9d3b6c1d143b59506e08c3f27eb088555801c.zip |
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)
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/data/Binder.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index d417944f80..3fb2d75c89 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -627,6 +627,31 @@ public class Binder<BEAN> implements Serializable { * 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> + * <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> * * @see HasValue#setRequiredIndicatorVisible(boolean) * @see HasValue#isEmpty() |