diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2018-02-02 12:25:35 +0200 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-02-02 12:25:35 +0200 |
commit | d2ef29e5b41d45f291d087760b02e212c75ff9eb (patch) | |
tree | f13c6e19627f96c11a8edce9d49e72e6867f3ed6 /client/src | |
parent | 875c98972e9c3da25a7c9c54cb267871921d4804 (diff) | |
download | vaadin-framework-d2ef29e5b41d45f291d087760b02e212c75ff9eb.tar.gz vaadin-framework-d2ef29e5b41d45f291d087760b02e212c75ff9eb.zip |
Add flush() implementation to DateField (#10518)
Fixes #10488
Diffstat (limited to 'client/src')
5 files changed, 60 insertions, 16 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractTextualDate.java b/client/src/main/java/com/vaadin/client/ui/VAbstractTextualDate.java index daa2701e2a..409dc0ef7f 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractTextualDate.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractTextualDate.java @@ -227,8 +227,19 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> } @Override - @SuppressWarnings("deprecation") public void onChange(ChangeEvent event) { + updateBufferedValues(); + sendBufferedValues(); + } + + @Override + public void updateBufferedValues() { + updateDate(); + bufferedDateString = text.getText(); + updateBufferedResolutions(); + } + + private void updateDate() { if (!text.getText().isEmpty()) { try { String enteredDate = text.getText(); @@ -259,10 +270,6 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> // remove possibly added invalid value indication removeStyleName(getStylePrimaryName() + PARSE_ERROR_CLASSNAME); } - - // always send the date string - bufferedDateString = text.getText(); - updateAndSendBufferedValues(); } /** @@ -270,7 +277,10 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> * then {@link #sendBufferedValues() sends} the values to the server. * * @since 8.2 + * @deprecated Use {@link #updateBufferedResolutions()} and + * {@link #sendBufferedValues()} instead. */ + @Deprecated protected final void updateAndSendBufferedValues() { updateBufferedResolutions(); sendBufferedValues(); @@ -285,8 +295,8 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> * method. * * <p> - * Note that this method should not send the buffered values, but use - * {@link #updateAndSendBufferedValues()} instead + * Note that this method should not send the buffered values. For that, use + * {@link #sendBufferedValues()}. * * @since 8.2 */ @@ -482,7 +492,8 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> date = getIsoFormatter().parse(isoDate); } setDate(date); - updateAndSendBufferedValues(); + updateBufferedResolutions(); + sendBufferedValues(); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/VDateField.java b/client/src/main/java/com/vaadin/client/ui/VDateField.java index 39aeda26c4..21ad59b4ba 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateField.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateField.java @@ -263,6 +263,19 @@ public abstract class VDateField<R extends Enum<R>> extends FlowPanel } /** + * Update buffered values {@link #bufferedDateString} and + * {@link #bufferedResolutions} that will be sent to the server. + * <p> + * This method should NOT send values to the server. + * <p> + * This method can be implemented by subclasses to update buffered values + * from component values. + * + * @since + */ + public abstract void updateBufferedValues(); + + /** * Sends the {@link #bufferedDateString} and {@link #bufferedResolutions} to * the server, and clears their values. * diff --git a/client/src/main/java/com/vaadin/client/ui/VDateFieldCalendar.java b/client/src/main/java/com/vaadin/client/ui/VDateFieldCalendar.java index 6e727ee640..42e8f9dc97 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateFieldCalendar.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateFieldCalendar.java @@ -38,14 +38,8 @@ public class VDateFieldCalendar super(GWT.create(VDateCalendarPanel.class), YEAR); } - /** - * TODO refactor: almost same method as in VPopupCalendar.updateValue - * <p> - * For internal use only. May be removed or replaced in the future. - */ @Override - @SuppressWarnings("deprecation") - public void updateValueFromPanel() { + public void updateBufferedValues() { // If field is invisible at the beginning, client can still be null when // this function is called. if (getClient() == null) { @@ -67,6 +61,18 @@ public class VDateFieldCalendar bufferedResolutions.put(DAY, date2.getDate()); } } + } + } + + /** + * TODO refactor: almost same method as in VPopupCalendar.updateValue + * <p> + * For internal use only. May be removed or replaced in the future. + */ + @Override + public void updateValueFromPanel() { + updateBufferedValues(); + if (bufferedResolutions != null) { sendBufferedValues(); } } diff --git a/client/src/main/java/com/vaadin/client/ui/VDateTimeFieldCalendar.java b/client/src/main/java/com/vaadin/client/ui/VDateTimeFieldCalendar.java index a635b8b615..a6c6cc75be 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateTimeFieldCalendar.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateTimeFieldCalendar.java @@ -43,7 +43,7 @@ public class VDateTimeFieldCalendar extends } @Override - public void updateValueFromPanel() { + public void updateBufferedValues() { // If field is invisible at the beginning, client can still be null when // this function is called. if (getClient() == null) { @@ -72,6 +72,13 @@ public class VDateTimeFieldCalendar extends } } } + } + } + + @Override + public void updateValueFromPanel() { + updateBufferedValues(); + if (bufferedResolutions != null) { sendBufferedValues(); } } diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/AbstractDateFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/AbstractDateFieldConnector.java index 35d1c1c4d1..b3ed6cd118 100644 --- a/client/src/main/java/com/vaadin/client/ui/datefield/AbstractDateFieldConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/datefield/AbstractDateFieldConnector.java @@ -167,6 +167,13 @@ public abstract class AbstractDateFieldConnector<R extends Enum<R>> calendar.updateAssistiveLabels(); } + @Override + public void flush() { + super.flush(); + getWidget().updateBufferedValues(); + getWidget().sendBufferedValues(); + } + private static Logger getLogger() { return Logger.getLogger(AbstractDateFieldConnector.class.getName()); } |