]> source.dussan.org Git - vaadin-framework.git/commitdiff
Replace setRequired & HasRequired with setRequiredIndicator
authorPekka Hyvönen <pekka@vaadin.com>
Thu, 27 Oct 2016 13:13:44 +0000 (16:13 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 1 Nov 2016 10:26:33 +0000 (10:26 +0000)
Vaadin 7 compatiblity fields still use setRequired via AbstractField (legacy).
Public setRequiredIndicator is added to AbstractField, AbstractMultiSelect and AbstractSingleSelect.
Internally it is still handled on AbstractComponent & -Connector level.
Changes the declarative syntax, required -> required-indicator-visible.

Fixes vaadin/framework8-issue#419

Change-Id: I940dc66944d27584bd78e5452aee627ee3abd03a

34 files changed:
client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java
client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java [new file with mode: 0644]
client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java
client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java
server/src/main/java/com/vaadin/data/HasRequired.java [deleted file]
server/src/main/java/com/vaadin/data/HasValue.java
server/src/main/java/com/vaadin/data/validator/NotEmptyValidator.java
server/src/main/java/com/vaadin/ui/AbstractComponent.java
server/src/main/java/com/vaadin/ui/AbstractField.java
server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java
shared/src/main/java/com/vaadin/shared/AbstractFieldState.java
shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java
shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java [new file with mode: 0644]
shared/src/main/java/com/vaadin/shared/ui/TabIndexState.java
shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java
shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java
shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java
uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java
uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java
uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java

index 86dbe672e07b83f51caba292e0b823fd02d5ea07..0dbe3cb33144603103fbc6acf2141471abe95eee 100644 (file)
@@ -25,11 +25,13 @@ import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.IsWidget;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.client.data.DataSource;
+import com.vaadin.client.ui.HasRequiredIndicator;
 import com.vaadin.shared.Range;
 import com.vaadin.shared.Registration;
 import com.vaadin.shared.data.selection.MultiSelectServerRpc;
 import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.ui.ListingJsonConstants;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 
 import elemental.json.JsonObject;
 
@@ -44,7 +46,8 @@ import elemental.json.JsonObject;
  * @since 8.0
  */
 public abstract class AbstractMultiSelectConnector
-        extends AbstractListingConnector<SelectionModel.Multi<?>> {
+        extends AbstractListingConnector<SelectionModel.Multi<?>>
+        implements HasRequiredIndicator {
 
     /**
      * Abstraction layer to help populate different multiselect widgets based on
@@ -148,13 +151,17 @@ public abstract class AbstractMultiSelectConnector
     protected void init() {
         super.init();
 
-        MultiSelectServerRpc rpcProxy = getRpcProxy(
-                MultiSelectServerRpc.class);
+        MultiSelectServerRpc rpcProxy = getRpcProxy(MultiSelectServerRpc.class);
         getMultiSelectWidget().addSelectionChangeListener(
                 (addedItems, removedItems) -> rpcProxy
                         .updateSelection(addedItems, removedItems));
     }
 
+    @Override
+    public RequiredIndicatorState getState() {
+        return (RequiredIndicatorState) super.getState();
+    }
+
     @Override
     public void setDataSource(DataSource<JsonObject> dataSource) {
         dataSource.addDataChangeHandler(this::onDataChange);
@@ -179,4 +186,9 @@ public abstract class AbstractMultiSelectConnector
         }
         getMultiSelectWidget().setItems(items);
     }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return getState().required && !isReadOnly();
+    }
 }
diff --git a/client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java b/client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java
new file mode 100644 (file)
index 0000000..5554b84
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.client.connectors;
+
+import com.google.gwt.event.dom.client.HasAllFocusHandlers;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ui.HasRequiredIndicator;
+import com.vaadin.shared.data.selection.SelectionModel;
+import com.vaadin.shared.ui.AbstractSingleSelectState;
+
+/**
+ * An abstract class for single selection connectors.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0.0
+ */
+public abstract class AbstractSingleSelectConnector<WIDGET extends Widget & HasAllFocusHandlers>
+        extends
+        AbstractFocusableListingConnector<WIDGET, SelectionModel.Single<?>>
+        implements HasRequiredIndicator {
+
+    @Override
+    public AbstractSingleSelectState getState() {
+        return (AbstractSingleSelectState) super.getState();
+    }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return getState().required && !isReadOnly();
+    }
+}
index a6d73be0c806978fb6e33a5614a72a1ef57ffb12..5fff238fd4ec784e323f8500e507266ee2c706a6 100644 (file)
@@ -668,6 +668,13 @@ public abstract class AbstractComponentConnector extends AbstractConnector
              */
             getWidget().setStylePrimaryName(state.primaryStyleName);
         }
+
+        // set required style name if components supports that
+        if (this instanceof HasRequiredIndicator) {
+            getWidget().setStyleName(StyleConstants.REQUIRED,
+                    ((HasRequiredIndicator) this).isRequiredIndicatorVisible());
+        }
+
         Profiler.leave("AbstractComponentConnector.updateWidgetStyleNames");
     }
 
index 18834b2f8b204dd1edc92e1d7d9db5b33a2ede4b..015b805ee131579f2e40dac3272d995e18bbfee0 100644 (file)
@@ -30,14 +30,6 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector
         return getState().modified;
     }
 
-    /**
-     * Checks whether the required indicator should be shown for the field.
-     *
-     * Required indicators are hidden if the field or its data source is
-     * read-only.
-     *
-     * @return true if required indicator should be shown
-     */
     @Override
     public boolean isRequiredIndicatorVisible() {
         return getState().required && !isReadOnly();
@@ -58,8 +50,5 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector
         // add / remove error style name to Fields
         setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
                 StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
-
-        getWidget().setStyleName(StyleConstants.REQUIRED,
-                isRequiredIndicatorVisible());
     }
 }
index 96fa5ea3cd7782d7b7cab9ace1efc55449457e8c..97f382453f2cc72107b8fd56e1cb142a764cb9a2 100644 (file)
@@ -22,6 +22,7 @@ import com.vaadin.client.connectors.AbstractListingConnector;
 import com.vaadin.client.connectors.data.HasDataSource;
 import com.vaadin.client.data.DataSource;
 import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
 import com.vaadin.client.ui.SimpleManagedLayout;
 import com.vaadin.client.ui.VComboBox;
 import com.vaadin.client.ui.VComboBox.DataReceivedHandler;
@@ -42,7 +43,8 @@ import elemental.json.JsonObject;
 @Connect(ComboBox.class)
 public class ComboBoxConnector
         extends AbstractListingConnector<SelectionModel.Single<?>>
-        implements HasDataSource, SimpleManagedLayout, HasErrorIndicator {
+        implements HasRequiredIndicator, HasDataSource, SimpleManagedLayout,
+        HasErrorIndicator {
 
     private ComboBoxServerRpc rpc = getRpcProxy(ComboBoxServerRpc.class);
     private SelectionServerRpc selectionRpc = getRpcProxy(
@@ -181,8 +183,8 @@ public class ComboBoxConnector
                 page = 0;
             }
         }
-        int adjustment = (getWidget().nullSelectionAllowed
-                && "".equals(getWidget().lastFilter)) ? 1 : 0;
+        int adjustment = getWidget().nullSelectionAllowed
+                && "".equals(getWidget().lastFilter) ? 1 : 0;
         int startIndex = Math.max(0,
                 page * getWidget().pageLength - adjustment);
         int pageLength = getWidget().pageLength > 0 ? getWidget().pageLength
@@ -331,4 +333,8 @@ public class ComboBoxConnector
         dataChangeHandlerRegistration.remove();
     }
 
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return getState().required && !isReadOnly();
+    }
 }
index 20c625a40d9344a02e6eb9c0a239ee3ae930feeb..18764f8b86ffbe0a838c6f25091e1726f12a78b6 100644 (file)
@@ -18,12 +18,11 @@ package com.vaadin.client.ui.nativeselect;
 
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.vaadin.client.annotations.OnStateChange;
-import com.vaadin.client.connectors.AbstractFocusableListingConnector;
+import com.vaadin.client.connectors.AbstractSingleSelectConnector;
 import com.vaadin.client.data.DataSource;
 import com.vaadin.client.ui.VNativeSelect;
 import com.vaadin.shared.Range;
 import com.vaadin.shared.Registration;
-import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.data.selection.SelectionServerRpc;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.nativeselect.NativeSelectState;
@@ -41,8 +40,8 @@ import elemental.json.JsonObject;
  * @since 8.0
  */
 @Connect(com.vaadin.ui.NativeSelect.class)
-public class NativeSelectConnector extends
-        AbstractFocusableListingConnector<VNativeSelect, SelectionModel.Single<?>> {
+public class NativeSelectConnector
+        extends AbstractSingleSelectConnector<VNativeSelect> {
 
     private HandlerRegistration selectionChangeRegistration;
     private Registration dataChangeRegistration;
index 5955037e65efb04b15b6a0406fd8611a33f75e46..940287d583766c10db1e6301b367d6021d0cb93e 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import com.vaadin.client.communication.StateChangeEvent;
 import com.vaadin.client.connectors.AbstractFocusableListingConnector;
 import com.vaadin.client.data.DataSource;
+import com.vaadin.client.ui.HasRequiredIndicator;
 import com.vaadin.client.ui.VCheckBoxGroup;
 import com.vaadin.shared.data.selection.MultiSelectServerRpc;
 import com.vaadin.shared.data.selection.SelectionModel;
@@ -35,8 +36,11 @@ import elemental.json.JsonObject;
 
 @Connect(CheckBoxGroup.class)
 // We don't care about the framework-provided selection model at this point
+// TODO refactor to extend AbstractMultiSelectConnector, maybe when
+// SelectionModel is removed from client side framwork8-issues#421
 public class CheckBoxGroupConnector extends
-        AbstractFocusableListingConnector<VCheckBoxGroup, SelectionModel<?>> {
+        AbstractFocusableListingConnector<VCheckBoxGroup, SelectionModel<?>>
+        implements HasRequiredIndicator {
 
     @Override
     protected void init() {
@@ -84,4 +88,9 @@ public class CheckBoxGroupConnector extends
         return (CheckBoxGroupState) super.getState();
     }
 
+    // TODO remove once this extends AbstractMultiSelectConnector
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return getState().required && !isReadOnly();
+    }
 }
index 4f3cad3c4ce1ddbd8b43a4276b07df650833f22e..13e39677d3d96d7fab876fe7af61a5728b6a683a 100644 (file)
@@ -21,12 +21,11 @@ import java.util.List;
 
 import com.vaadin.client.annotations.OnStateChange;
 import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.connectors.AbstractFocusableListingConnector;
+import com.vaadin.client.connectors.AbstractSingleSelectConnector;
 import com.vaadin.client.data.DataSource;
 import com.vaadin.client.ui.VRadioButtonGroup;
 import com.vaadin.shared.Range;
 import com.vaadin.shared.Registration;
-import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.data.selection.SelectionServerRpc;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.optiongroup.RadioButtonGroupState;
@@ -35,8 +34,8 @@ import com.vaadin.ui.RadioButtonGroup;
 import elemental.json.JsonObject;
 
 @Connect(RadioButtonGroup.class)
-public class RadioButtonGroupConnector extends
-        AbstractFocusableListingConnector<VRadioButtonGroup, SelectionModel.Single<?>> {
+public class RadioButtonGroupConnector
+        extends AbstractSingleSelectConnector<VRadioButtonGroup> {
 
     private Registration selectionChangeRegistration;
     private Registration dataChangeRegistration;
index eb6255e37a9dc0c530426f380c19fd5b2f09d44c..f8188faa4d76c26cdf24386208f295df03118c6a 100644 (file)
@@ -1433,42 +1433,11 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
         removePropertyListeners();
     }
 
-    /**
-     * Is this field required. Required fields must filled by the user.
-     *
-     * If the field is required, it is visually indicated in the user interface.
-     * Furthermore, setting field to be required implicitly adds "non-empty"
-     * validator and thus isValid() == false or any isEmpty() fields. In those
-     * cases validation errors are not painted as it is obvious that the user
-     * must fill in the required fields.
-     *
-     * On the other hand, for the non-required fields isValid() == true if the
-     * field isEmpty() regardless of any attached validators.
-     *
-     *
-     * @return <code>true</code> if the field is required, otherwise
-     *         <code>false</code>.
-     */
     @Override
     public boolean isRequired() {
         return getState(false).required;
     }
 
-    /**
-     * Sets the field required. Required fields must filled by the user.
-     *
-     * If the field is required, it is visually indicated in the user interface.
-     * Furthermore, setting field to be required implicitly adds "non-empty"
-     * validator and thus isValid() == false or any isEmpty() fields. In those
-     * cases validation errors are not painted as it is obvious that the user
-     * must fill in the required fields.
-     *
-     * On the other hand, for the non-required fields isValid() == true if the
-     * field isEmpty() regardless of any attached validators.
-     *
-     * @param required
-     *            Is the field required.
-     */
     @Override
     public void setRequired(boolean required) {
         getState().required = required;
index d98153da293b2a77df154c57b6cac06596ab3b75..1594bc28b5bb041eff8499f94680057fecf48fe1 100644 (file)
@@ -16,8 +16,6 @@
 
 package com.vaadin.v7.ui;
 
-import com.vaadin.data.HasRequired;
-import com.vaadin.data.HasValue.ValueChangeEvent;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Component.Focusable;
 import com.vaadin.v7.data.BufferedValidatable;
@@ -48,7 +46,7 @@ import com.vaadin.v7.data.Property;
 @Deprecated
 public interface Field<T> extends Component, BufferedValidatable, Property<T>,
         Property.ValueChangeNotifier, Property.ValueChangeListener,
-        Property.Editor, Focusable, HasRequired {
+        Property.Editor, Focusable {
     /**
      * Is this field required.
      *
@@ -58,7 +56,6 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>,
      *         <code>false</code>.
      * @since 3.1
      */
-    @Override
     public boolean isRequired();
 
     /**
@@ -68,7 +65,6 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>,
      *            Is the field required.
      * @since 3.1
      */
-    @Override
     public void setRequired(boolean required);
 
     /**
diff --git a/server/src/main/java/com/vaadin/data/HasRequired.java b/server/src/main/java/com/vaadin/data/HasRequired.java
deleted file mode 100644 (file)
index cca6fcd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.data;
-
-import com.vaadin.ui.Component;
-
-/**
- * Interface implemented by field which can be marked as required. A required
- * status is handled by the parent layout.
- *
- * @since 8.0
- * @author Vaadin Ltd
- */
-public interface HasRequired extends Component {
-
-    /**
-     * Sets whether the field is required or not.
-     *
-     * If the field is required, it is visually indicated in the user interface.
-     *
-     * @param required
-     *            <code>true</code> to make the field required,
-     *            <code>false</code> otherwise
-     */
-    public void setRequired(boolean required);
-
-    /**
-     * Checks whether the field is required.
-     *
-     * @return <code>true</code> if the field is required, <code>false</code>
-     *         otherwise
-     */
-    public boolean isRequired();
-
-}
index aa130344b2a7aa42544cbfdc73d0115d9ba3682e..e02297b7f4b05ea026de252e6b7028fcfa410366 100644 (file)
@@ -94,7 +94,7 @@ public interface HasValue<V> extends Serializable {
          * This a shorthand method for {@link HasValue#getValue()} for the event
          * source {@link #getSource()}. Thus the value is always the most recent
          * one, even if has been changed after the firing of this event.
-         * 
+         *
          * @see HasValue#getValue()
          *
          * @return the new value
@@ -217,4 +217,22 @@ public interface HasValue<V> extends Serializable {
     public default boolean isEmpty() {
         return Objects.equals(getValue(), getEmptyValue());
     }
+
+    /**
+     * Sets the required indicator visible or not.
+     * <p>
+     * If set visible, it is visually indicated in the user interface.
+     *
+     * @param requiredIndicatorVisible
+     *            <code>true</code> to make the required indicator visible,
+     *            <code>false</code> if not
+     */
+    public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible);
+
+    /**
+     * Checks whether the required indicator is visible.
+     *
+     * @return <code>true</code> if visible, <code>false</code> if not
+     */
+    public boolean isRequiredIndicatorVisible();
 }
index 99532c34d1e5d3bd2d3d17b04cef86f01e5b396f..b03353894936925fc9202f8fab9c8cecc9c02ea6 100644 (file)
@@ -17,7 +17,7 @@ package com.vaadin.data.validator;
 
 import java.util.Objects;
 
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
 import com.vaadin.data.Result;
 import com.vaadin.data.Validator;
 import com.vaadin.data.util.converter.ValueContext;
@@ -34,21 +34,22 @@ import com.vaadin.data.util.converter.ValueContext;
  * <p>
  * If the field is required, it is visually indicated in the user interface.
  * Furthermore, required fields requires "non-empty" validator. So in addition
- * to call {@link HasRequired#setRequired(boolean)} method one should add an
- * instance of this validator explicitly so the code looks like this:
+ * to call {@link HasRequired#setRequiredIndicatorVisible(boolean)} method one
+ * should add an instance of this validator explicitly so the code looks like
+ * this:
  *
  * <pre>
  * <code>
  * Binder<Bean,String, String> binder = new Binder<>();
  * TextField name = new TextField();
- * name.setRequired(true);
+ * name.setRequiredIndicatorVisible(true);
  * binder.forField(name).withValidator(
  *      new NonEmptyValidator("Name cannot be empty"))
  *              .bind(Bean::getName, Bean::setName);
  * </code>
  * </pre>
  *
- * @see HasRequired
+ * @see HasValue#setRequiredIndicatorVisible(boolean)
  * @author Vaadin Ltd
  * @since 8.0
  *
index 6cbf745851d26d5a928a68d1e590e3c945a1e452..8711b601e6f3f94420d247b3663e9f3800f65159 100644 (file)
@@ -60,6 +60,7 @@ import com.vaadin.shared.EventId;
 import com.vaadin.shared.MouseEventDetails;
 import com.vaadin.shared.Registration;
 import com.vaadin.shared.ui.ComponentStateUtil;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 import com.vaadin.shared.util.SharedUtil;
 import com.vaadin.ui.declarative.DesignAttributeHandler;
 import com.vaadin.ui.declarative.DesignContext;
@@ -1045,7 +1046,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
     }
 
     /**
-     * Returns true if the component is responsive
+     * Returns true if the component is responsive.
      *
      * @since 7.5.0
      * @return true if the component is responsive
@@ -1370,6 +1371,58 @@ public abstract class AbstractComponent extends AbstractClientConnector
                 listener);
     }
 
+    /**
+     * Sets the visibility of the required indicator. <strong>NOTE: Does not
+     * apply for all components!</strong>.
+     * <p>
+     * If the component supports the required indicator (state extends
+     * {@link RequiredIndicatorState}), then expose this method and
+     * {@link #isRequiredIndicatorVisible()} as {@code public} in the component
+     * and call this method.
+     * <p>
+     * This method will throw a {@link IllegalStateException} if the component
+     * state (returned by {@link #getState()}) does not inherit
+     * {@link RequiredIndicatorState}.
+     *
+     * @param visible
+     *            <code>true</code> to make the required indicator visible,
+     *            <code>false</code> if not
+     */
+    protected void setRequiredIndicatorVisible(boolean visible) {
+        if (getState(false) instanceof RequiredIndicatorState) {
+            ((RequiredIndicatorState) getState()).required = visible;
+        } else {
+            throw new IllegalStateException(
+                    "This component does not support the required indicator, since state is of type "
+                            + getStateType().getSimpleName()
+                            + " and does not inherit "
+                            + RequiredIndicatorState.class.getSimpleName());
+        }
+    }
+
+    /**
+     * Checks whether the required indicator is visible or not. <strong>NOTE:
+     * Does not apply for all components!</strong>.
+     * <p>
+     * This method will throw a {@link IllegalStateException} if the component
+     * state (returned by {@link #getState()}) does not inherit
+     * {@link RequiredIndicatorState}.
+     *
+     * @return <code>true</code> if visible, <code>false</code> if not
+     * @see #setRequiredIndicatorVisible(boolean)
+     */
+    protected boolean isRequiredIndicatorVisible() {
+        if (getState(false) instanceof RequiredIndicatorState) {
+            return ((RequiredIndicatorState) getState(false)).required;
+        } else {
+            throw new IllegalStateException(
+                    "This component does not support the required indicator, since state is of type "
+                            + getStateType().getSimpleName()
+                            + " and does not inherit "
+                            + RequiredIndicatorState.class.getSimpleName());
+        }
+    }
+
     private static final Logger getLogger() {
         return Logger.getLogger(AbstractComponent.class.getName());
     }
index 4add30183eacd8e16405b5114ddada4ba2cf8b3e..065825b5ad7adcd7cdf11e073721749601da1b10 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Objects;
 import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Element;
 
-import com.vaadin.data.HasRequired;
 import com.vaadin.data.HasValue;
 import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.Registration;
@@ -49,7 +48,7 @@ import com.vaadin.util.ReflectTools;
  *            the input value type
  */
 public abstract class AbstractField<T> extends AbstractComponent
-        implements HasValue<T>, HasRequired, Focusable {
+        implements HasValue<T>, Focusable {
 
     @Deprecated
     private static final Method VALUE_CHANGE_METHOD = ReflectTools.findMethod(
@@ -214,12 +213,12 @@ public abstract class AbstractField<T> extends AbstractComponent
     }
 
     @Override
-    public void setRequired(boolean required) {
-        getState().required = required;
+    public void setRequiredIndicatorVisible(boolean visible) {
+        super.setRequiredIndicatorVisible(visible);
     }
 
     @Override
-    public boolean isRequired() {
-        return getState(false).required;
+    public boolean isRequiredIndicatorVisible() {
+        return super.isRequiredIndicatorVisible();
     }
 }
index 5ab6951f8d7d519c9270ce64fea763f831b09b5f..99c168253684d4a0ef8979ebbde617d7adba53f9 100644 (file)
@@ -37,6 +37,7 @@ import com.vaadin.shared.data.selection.MultiSelectServerRpc;
 import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.data.selection.SelectionModel.Multi;
 import com.vaadin.shared.ui.ListingJsonConstants;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 import com.vaadin.util.ReflectTools;
 
 import elemental.json.JsonObject;
@@ -472,4 +473,24 @@ public abstract class AbstractMultiSelect<T>
         this.itemEnabledProvider = itemEnabledProvider;
     }
 
+    @Override
+    public void setRequiredIndicatorVisible(boolean visible) {
+        super.setRequiredIndicatorVisible(visible);
+    }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return super.isRequiredIndicatorVisible();
+    }
+
+    @Override
+    protected RequiredIndicatorState getState() {
+        return (RequiredIndicatorState) super.getState();
+    }
+
+    @Override
+    protected RequiredIndicatorState getState(boolean markAsDirty) {
+        return (RequiredIndicatorState) super.getState(markAsDirty);
+    };
+
 }
index c4405f06b12c5663fdc7480c69ed59a6bc4217f6..272acf3b091453c528833e43d01420016bede5ca 100644 (file)
@@ -306,7 +306,7 @@ public abstract class AbstractSingleSelect<T> extends
      * The call is delegated to {@link #getSelectedItem()}
      *
      * @return the current selection, may be {@code null}
-     * 
+     *
      * @see #getSelectedItem()
      * @see Single#getSelectedItem
      */
@@ -321,7 +321,7 @@ public abstract class AbstractSingleSelect<T> extends
      * value is {@code null} then it deselects currently selected item.
      * <p>
      * The call is delegated to {@link #setSelectedItem(Object)}.
-     * 
+     *
      * @see #setSelectedItem(Object)
      * @see Single#setSelectedItem(Object)
      *
@@ -349,4 +349,14 @@ public abstract class AbstractSingleSelect<T> extends
     protected AbstractSingleSelectState getState(boolean markAsDirty) {
         return (AbstractSingleSelectState) super.getState(markAsDirty);
     }
+
+    @Override
+    public void setRequiredIndicatorVisible(boolean visible) {
+        super.setRequiredIndicatorVisible(visible);
+    }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return super.isRequiredIndicatorVisible();
+    }
 }
index ba00773fec71ccf91964a4db9b94be0e9ffdf1be..f474e51e993b8abafc5c6e6da454e278c270435b 100644 (file)
@@ -710,6 +710,16 @@ public class ColorPickerPopup extends Window implements HasValue<Color> {
         }
     };
 
+    @Override
+    public void setRequiredIndicatorVisible(boolean visible) {
+        super.setRequiredIndicatorVisible(visible);
+    }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return super.isRequiredIndicatorVisible();
+    }
+
     private static Logger getLogger() {
         return Logger.getLogger(ColorPickerPopup.class.getName());
     }
index 67724d134b2b1b49a47649648c992a769b33fd15..27e5690e3c5920639e1ad0d719058cf338d8eb48 100644 (file)
@@ -185,4 +185,14 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
     protected String getCss(Component c) {
         return "background: " + color.getCSS();
     }
+
+    @Override
+    public void setRequiredIndicatorVisible(boolean visible) {
+        super.setRequiredIndicatorVisible(visible);
+    }
+
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return super.isRequiredIndicatorVisible();
+    }
 }
index df7b64b67198682b41e611af0bb3ecc4570d3103..e22905c9f358b8ee8770876f6fdf74c460665e69 100644 (file)
@@ -28,7 +28,7 @@ import com.vaadin.ui.AbstractField;
  * declarative test for a real component should extend it and implement abstract
  * methods to be able to test the common properties. Components specific
  * properties should be tested additionally in the subclasses implementations.
- * 
+ *
  * @author Vaadin Ltd
  *
  */
@@ -39,10 +39,11 @@ public abstract class AbstractFieldDeclarativeTest<T extends AbstractField<V>, V
     public void requiredDeserialization()
             throws InstantiationException, IllegalAccessException {
         boolean isRequired = true;
-        String design = String.format("<%s required/>", getComponentTag());
+        String design = String.format("<%s required-indicator-visible/>",
+                getComponentTag());
 
         T component = getComponentClass().newInstance();
-        component.setRequired(isRequired);
+        component.setRequiredIndicatorVisible(isRequired);
         testRead(design, component);
         testWrite(design, component);
     }
index 5040e91d48d090fd2be1d22807e3922cc56906b3..e24880c3af2cc75154e361f287a18c689967f291 100644 (file)
@@ -15,7 +15,7 @@
  */
 package com.vaadin.shared;
 
-import com.vaadin.shared.ui.TabIndexState;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for {@link com.vaadin.ui.AbstractField}.
@@ -24,8 +24,7 @@ import com.vaadin.shared.ui.TabIndexState;
  * @since 7.0.0
  *
  */
-public class AbstractFieldState extends TabIndexState {
+public class AbstractFieldState extends RequiredIndicatorState {
     public boolean hideErrors = false;
-    public boolean required = false;
     public boolean modified = false;
 }
index 98aad0bf37f2509edacf37fb2eb50b1dcd02d305..da4510bfdb6e7b59ec75468c751d57abc77a1753 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2016 Vaadin Ltd.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,7 +22,7 @@ package com.vaadin.shared.ui;
  *
  * @since 8.0
  */
-public class AbstractSingleSelectState extends TabIndexState {
+public class AbstractSingleSelectState extends RequiredIndicatorState {
 
     /**
      * The key of the currently selected item or {@code null} if no item is
diff --git a/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java b/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java
new file mode 100644 (file)
index 0000000..b26a8ce
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui;
+
+/**
+ * State for components that can show the required indicator.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0.0
+ *
+ */
+public class RequiredIndicatorState extends TabIndexState {
+
+    /**
+     * Is the required indicator visible or not.
+     */
+    public boolean required;
+
+}
index f0c709d3732c133d4e72a73e45fedbd4787a860c..485448e758210500ef3277bbc34861d933c3f01a 100644 (file)
@@ -19,7 +19,7 @@ import com.vaadin.shared.AbstractComponentState;
 import com.vaadin.shared.annotations.NoLayout;
 
 /**
- * Interface implemented by state classes that support tab indexes.
+ * State for components that support tab indexes.
  *
  * @author Vaadin Ltd
  * @since 7.0.0
index 8999f3c7399167671b1493649fdaaeb2bf649c32..8992dc66473496f5b0697882cc9dd10ae5618071 100644 (file)
@@ -16,7 +16,7 @@
 package com.vaadin.shared.ui.listselect;
 
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.ui.TabIndexState;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for ListSelect component.
@@ -24,7 +24,7 @@ import com.vaadin.shared.ui.TabIndexState;
  * @author Vaadin Ltd
  *
  */
-public class ListSelectState extends TabIndexState {
+public class ListSelectState extends RequiredIndicatorState {
     {
         primaryStyleName = "v-select";
     }
index 2decfdd49c52f324f5089429915226e5cb302676..82695a913cfc0cae2140a54931913b4db759fdbc 100644 (file)
@@ -16,7 +16,7 @@
 package com.vaadin.shared.ui.optiongroup;
 
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.AbstractFieldState;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for the CheckBoxGroup component.
@@ -24,7 +24,7 @@ import com.vaadin.shared.AbstractFieldState;
  * @author Vaadin Ltd.
  * @since 8.0
  */
-public class CheckBoxGroupState extends AbstractFieldState {
+public class CheckBoxGroupState extends RequiredIndicatorState {
 
     {
         primaryStyleName = "v-select-optiongroup";
index a6b09c0e918639e05b43528f1b6996eb5577a57f..fe1f1fab2313388e129052b23d0689d237e121f2 100644 (file)
 package com.vaadin.shared.ui.twincolselect;
 
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.ui.TabIndexState;
+import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for the TwinColSelect component.
  *
  * @since 7.0
  */
-public class TwinColSelectState extends TabIndexState {
+public class TwinColSelectState extends RequiredIndicatorState {
     {
         primaryStyleName = "v-select-twincol";
     }
index 8dce9c73e2872852754da9b2ae39b6e673bb545a..f34c6630290e3d376fda044662e0beee2106c5f6 100644 (file)
@@ -5,7 +5,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
 import com.vaadin.server.Resource;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.server.UserError;
@@ -109,8 +109,10 @@ public abstract class AbstractComponentTestCase<T extends AbstractComponent>
 
     // TODO Move to AbstractFieldTestCase
     protected Command<T, Boolean> requiredCommand = (c, enabled, data) -> {
-        if (c instanceof HasRequired) {
-            ((HasRequired) c).setRequired(enabled);
+        if (c instanceof HasValue) {
+            ((HasValue) c).setRequiredIndicatorVisible(enabled);
+        } else if (c instanceof Field) {
+            ((Field) c).setRequired(enabled);
         } else {
             throw new IllegalArgumentException(c.getClass().getName()
                     + " is not a field and cannot be set to required");
index 1010a42e7d0468ff560bf9014de7b4f40ae947bf..591bf599cba3abba1af2c5d0ce4d0461f30ca864 100644 (file)
@@ -4,7 +4,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Alignment;
@@ -13,6 +13,7 @@ import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.v7.data.Item;
+import com.vaadin.v7.ui.Field;
 import com.vaadin.v7.ui.NativeSelect;
 
 public abstract class ComponentTestCase<T extends AbstractComponent>
@@ -71,7 +72,8 @@ public abstract class ComponentTestCase<T extends AbstractComponent>
         actions.add(createReadonlyAction(false));
 
         actions.add(createErrorIndicatorAction(false));
-        if (HasRequired.class.isAssignableFrom(getTestClass())) {
+        if (HasValue.class.isAssignableFrom(getTestClass())
+                || Field.class.isAssignableFrom(getTestClass())) {
             actions.add(createRequiredAction(false));
         }
 
index d08194681e220151e55826bc588ec865852e849f..794db5e0969d6de38d0a1f8370c5949976f22d40 100644 (file)
@@ -15,7 +15,7 @@ public class DatePopupStyleName extends TestBase {
         final AbstractDateField df = new TestDateField();
         df.setValue(LocalDate.of(1970, 1, 15));
         df.setWidth("200px");
-        df.setRequired(true);
+        df.setRequiredIndicatorVisible(true);
         df.setComponentError(new UserError("abc"));
         df.addStyleName("popup-style");
         addComponent(df);
index b995fe9093913ecd259d7196387bb97e37869fda..5c8788f53ec4c65117f6b029b72f12c9b80fa0c7 100644 (file)
@@ -3,7 +3,7 @@ package com.vaadin.tests.layouts;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.server.UserError;
 import com.vaadin.tests.components.TestBase;
@@ -24,6 +24,7 @@ import com.vaadin.ui.VerticalLayout;
 import com.vaadin.v7.data.Item;
 import com.vaadin.v7.data.Property.ValueChangeEvent;
 import com.vaadin.v7.data.Property.ValueChangeListener;
+import com.vaadin.v7.ui.Field;
 import com.vaadin.v7.ui.NativeSelect;
 import com.vaadin.v7.ui.OptionGroup;
 import com.vaadin.v7.ui.PasswordField;
@@ -140,8 +141,10 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
 
     protected void setRequired(boolean value) {
         for (AbstractComponent c : components) {
-            if (c instanceof HasRequired) {
-                ((HasRequired) c).setRequired(value);
+            if (c instanceof HasValue) {
+                ((HasValue) c).setRequiredIndicatorVisible(value);
+            } else if (c instanceof Field) {
+                ((Field) c).setRequired(value);
             }
         }
 
index f06db44b5c22aeb0ae17acc01454ae28b61cb743..6c7b1129103cac7cf8b049d38e32f0fd1bdc9da2 100644 (file)
@@ -25,7 +25,7 @@ public class FormLayoutWithInvisibleComponent extends TestBase {
         CheckBox control = new CheckBox("Messages On/Off");
         control.addValueChangeListener(event -> {
             messages.setVisible(event.getValue());
-            messages.setRequired(true);
+            messages.setRequiredIndicatorVisible(true);
             messages.setCaption("Messages visible");
         });
         formLayout.addComponent(control);
index 4d1f0213c41dbf9b92f46ea8c87bac0f4929ff4e..112965d06a48b15010cec0b8f43fbcd3f874938e 100644 (file)
@@ -343,7 +343,7 @@ public class OrderedLayoutBasics extends TestBase {
 
         tf = new TextArea("100% high TextField");
         tf.setCaption(null);
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setValue("100% high Field");
         tf.setHeight("100%");
         tf.setWidth("100px");
@@ -352,7 +352,7 @@ public class OrderedLayoutBasics extends TestBase {
 
         tf = new TextArea("100% high TextField");
         tf.setCaption("100% high TextField");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setValue("100% high Field");
         tf.setHeight("100%");
         tf.setWidth("100px");
@@ -602,7 +602,7 @@ public class OrderedLayoutBasics extends TestBase {
         tf.setValue("60% x 100% TextField");
         tf.setWidth("100%");
         tf.setHeight("100%");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         // tf.setComponentError(new UserError("It's broken!"));
 
         // tf.setHeight("100%");
@@ -617,7 +617,7 @@ public class OrderedLayoutBasics extends TestBase {
         tf.setValue("60% x 60% TextField");
         tf.setWidth("100%");
         tf.setHeight("60%");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         ol.addComponent(tf);
         ol.setExpandRatio(tf, 1f);
         ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
@@ -696,7 +696,7 @@ public class OrderedLayoutBasics extends TestBase {
             tf.setValue("200x200 TextField");
             tf.setWidth("200px");
             tf.setHeight("200px");
-            tf.setRequired(true);
+            tf.setRequiredIndicatorVisible(true);
             // tf.setComponentError(new UserError("It's broken!"));
 
             // tf.setHeight("100%");
@@ -723,9 +723,9 @@ public class OrderedLayoutBasics extends TestBase {
             tf = new TextArea("200x200px Field");
             tf.setCaption("This one has a caption");
             tf.setWidth("200px");
-            tf.setHeight(((i + 1) * 50) + "px");
+            tf.setHeight((i + 1) * 50 + "px");
             tf.setValue(tf.getWidth() + "x" + tf.getHeight() + " TextField");
-            tf.setRequired(true);
+            tf.setRequiredIndicatorVisible(true);
             // tf.setComponentError(new UserError("It's broken!"));
 
             // tf.setHeight("100%");
@@ -814,7 +814,7 @@ public class OrderedLayoutBasics extends TestBase {
 
         tf = new TextField(
                 "A very long caption which is probably much longer than the field and includes indicators");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("abc123"));
         ol.addComponent(tf);
 
@@ -852,7 +852,7 @@ public class OrderedLayoutBasics extends TestBase {
         tf = new TextField(
                 "A long caption which is probably much longer than the field");
         tf.setValue("Undefined width");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -861,7 +861,7 @@ public class OrderedLayoutBasics extends TestBase {
                 "A very long caption which is probably much longer than the field and includes indicators");
         tf.setValue("Undefined width");
         tf.setIcon(new ThemeResource("icons/16/document-add.png"));
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("abc123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -905,7 +905,7 @@ public class OrderedLayoutBasics extends TestBase {
                 "A long caption which is probably much longer than the field");
         tf.setValue("100% wide field, ratio 2");
         tf.setSizeFull();
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -916,7 +916,7 @@ public class OrderedLayoutBasics extends TestBase {
         tf.setValue("100% wide field, ratio 3");
         tf.setSizeFull();
         tf.setIcon(new ThemeResource("icons/16/document-add.png"));
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("abc123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -959,7 +959,7 @@ public class OrderedLayoutBasics extends TestBase {
                 "A long caption which is probably much longer than the field");
         tf.setWidth("250px");
         tf.setValue("250px wide field");
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -969,7 +969,7 @@ public class OrderedLayoutBasics extends TestBase {
         tf.setValue("200px wide field");
         tf.setWidth("200px");
         tf.setIcon(new ThemeResource("icons/16/document-add.png"));
-        tf.setRequired(true);
+        tf.setRequiredIndicatorVisible(true);
         tf.setComponentError(new UserError("abc123"));
         ol.addComponent(tf);
         ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -1209,7 +1209,7 @@ public class OrderedLayoutBasics extends TestBase {
         ta.setValue("60% x 100% TextField");
         ta.setWidth("60%");
         ta.setHeight("100%");
-        ta.setRequired(true);
+        ta.setRequiredIndicatorVisible(true);
         ta.setRows(2);
 
         ol.addComponent(ta);
index bd9df1e8f8378bd7d445b32a2969d923748ef016..db29239bf30cb2b7f00f2c252beb1e23bdb65379 100644 (file)
@@ -26,7 +26,7 @@ public class CheckBoxWithPropertyDataSource extends CheckBox {
     }
 
     public void validate() {
-        if (isRequired() && !getValue()) {
+        if (isRequiredIndicatorVisible() && !getValue()) {
             throw new InvalidValueException(
                     "Required CheckBox should be checked");
         }