Skip to content

Commit 5ad981a

Browse files
committed
GMD Addins - DateInputParser - added convenience method with components getter also make sure the clear the valuebox whenever we have invalid entry.
1 parent 635b333 commit 5ad981a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/main/java/gwt/material/design/addins/client/inputmask/MaterialDateInputMask.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
public class MaterialDateInputMask extends AbstractValueWidget<Date>
4242
implements HasFieldTypes, HasLabel, HasInputMaskHandlers, HasPlaceholder, HasReadOnly, HasActive, HasToggleReadOnlyHandler, HasAutocomplete, HasPasteHandlers, HasFieldSensitivity {
4343

44-
private String format = "YYYY-mm-dd";
45-
private MaterialInputMask inputMask;
46-
private DateInputParser inputParser;
44+
protected String format = "YYYY-mm-dd";
45+
protected MaterialInputMask inputMask;
46+
protected DateInputParser inputParser;
4747

4848
public MaterialDateInputMask() {
4949
super(DOM.createDiv());
@@ -220,6 +220,22 @@ public HandlerRegistration addPasteHandler(PasteEvent.PasteEventHandler handler)
220220
return inputMask.addPasteHandler(handler);
221221
}
222222

223+
public DateInputParser getInputParser() {
224+
return inputParser;
225+
}
226+
227+
public void setInputParser(DateInputParser inputParser) {
228+
this.inputParser = inputParser;
229+
}
230+
231+
public MaterialInputMask getInputMask() {
232+
return inputMask;
233+
}
234+
235+
public void setInputMask(MaterialInputMask inputMask) {
236+
this.inputMask = inputMask;
237+
}
238+
223239
@Override
224240
public String getPlaceholder() {
225241
return inputMask.getPlaceholder();

src/main/java/gwt/material/design/addins/client/inputmask/base/DateInputParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class DateInputParser<T extends AbstractInputMask<String>> {
2828

29-
private final T valuebox;
29+
protected final T valuebox;
3030

3131
public DateInputParser(T valuebox) {
3232
this.valuebox = valuebox;
@@ -43,6 +43,8 @@ public Date parseDate(String format) {
4343
public void setValue(String format, Date value) {
4444
if (value != null) {
4545
valuebox.setValue(DateTimeFormat.getFormat(format).format(value), true);
46+
} else {
47+
valuebox.clear();
4648
}
4749
}
4850

0 commit comments

Comments
 (0)