summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VTextualDate.java64
-rw-r--r--client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java1
-rw-r--r--client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java3
3 files changed, 25 insertions, 43 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VTextualDate.java b/client/src/main/java/com/vaadin/client/ui/VTextualDate.java
index 7b83a5622d..b7c89c6397 100644
--- a/client/src/main/java/com/vaadin/client/ui/VTextualDate.java
+++ b/client/src/main/java/com/vaadin/client/ui/VTextualDate.java
@@ -56,16 +56,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
/** For internal use only. May be removed or replaced in the future. */
public boolean lenient;
- private static final String CLASSNAME_PROMPT = "prompt";
-
- /** For internal use only. May be removed or replaced in the future. */
- public static final String ATTR_INPUTPROMPT = "prompt";
-
- /** For internal use only. May be removed or replaced in the future. */
- public String inputPrompt = "";
-
- private boolean prompting = false;
-
public VTextualDate() {
super();
text = new TextBox();
@@ -75,10 +65,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
public void onFocus(FocusEvent event) {
text.addStyleName(VTextField.CLASSNAME + "-"
+ VTextField.CLASSNAME_FOCUS);
- if (prompting) {
- text.setText("");
- setPrompting(false);
- }
if (getClient() != null && getClient()
.hasEventListeners(VTextualDate.this, EventId.FOCUS)) {
getClient().updateVariable(getId(), EventId.FOCUS, "",
@@ -95,11 +81,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
text.removeStyleName(VTextField.CLASSNAME + "-"
+ VTextField.CLASSNAME_FOCUS);
String value = getText();
- setPrompting(inputPrompt != null
- && (value == null || "".equals(value)));
- if (prompting) {
- text.setText(readonly ? "" : inputPrompt);
- }
if (getClient() != null && getClient()
.hasEventListeners(VTextualDate.this, EventId.BLUR)) {
getClient().updateVariable(getId(), EventId.BLUR, "", true);
@@ -204,15 +185,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
text.setEnabled(enabled);
}
- protected void setPrompting(boolean prompting) {
- this.prompting = prompting;
- if (prompting) {
- addStyleDependentName(CLASSNAME_PROMPT);
- } else {
- removeStyleDependentName(CLASSNAME_PROMPT);
- }
- }
-
@Override
@SuppressWarnings("deprecation")
public void onChange(ChangeEvent event) {
@@ -307,23 +279,35 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
text.setFocus(true);
}
- protected String getText() {
- if (prompting) {
- return "";
+ /**
+ * Sets the placeholder for this textual date input.
+ *
+ * @param placeholder
+ * the placeholder to set, or {@code null} to clear
+ */
+ public void setPlaceholder(String placeholder) {
+ if (placeholder != null) {
+ text.getElement().setAttribute("placeholder", placeholder);
+ } else {
+ text.getElement().removeAttribute("placeholder");
}
+ }
+
+ /**
+ * Gets the set placeholder this textual date input, or an empty string if
+ * none is set.
+ *
+ * @return the placeholder or an empty string if none set
+ */
+ public String getPlaceHolder() {
+ return text.getElement().getAttribute("placeholder");
+ }
+
+ protected String getText() {
return text.getText();
}
protected void setText(String text) {
- if (inputPrompt != null && (text == null || "".equals(text))
- && !this.text.getStyleName().contains(VTextField.CLASSNAME + "-"
- + VTextField.CLASSNAME_FOCUS)) {
- text = readonly ? "" : inputPrompt;
- setPrompting(true);
- } else {
- setPrompting(false);
- }
-
this.text.setText(text);
}
diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java
index 7161283176..4a08399bdf 100644
--- a/client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java
@@ -23,6 +23,7 @@ import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.ui.PopupPanel;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.UIDL;
+import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.VPopupCalendar;
diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java
index 45504cebd0..bf77d3b25f 100644
--- a/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java
@@ -38,9 +38,6 @@ public class TextualDateConnector extends AbstractDateFieldConnector {
getWidget().formatStr = uidl.getStringAttribute("format");
}
- getWidget().inputPrompt = uidl
- .getStringAttribute(VTextualDate.ATTR_INPUTPROMPT);
-
getWidget().lenient = !uidl.getBooleanAttribute("strict");
getWidget().buildDate();