Hi,
-- I did it like this. Any comment/improvement ?
public class DateEditor extends Composite implements LeafValueEditor<Date> {
static final DateTimeFormat html5Fmt = DateTimeFormat.getFormat("yyyy-MM-dd");
TextBox textBox;
public DateEditor() {
super();
textBox = new TextBox(createDateInput());
initWidget(textBox);
}
@Override
public void setValue(Datevalue) {
if (value == null)
{
textBox.setText("");
}
else
{
textBox.setText(html5Fmt.format(value));
}
}
@Override
public Date getValue() {
// TODO Auto-generated method stub
String value = textBox.getText();
if (value == null || value.trim().length() == 0) {
return null;
}
return new Date(html5Fmt.parse(value));
}
private static native InputElement createDateInput() /*-{
var input = document.createElement("input");
input.setAttribute("type", "date");
return input;
}-*/;
}
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment