SGWT: 4.1p
FF: 26
I have this custom CanvasItem that I'd like to have validate when form.validate() is called. I tried overloading validate (see below), but it doesn't seem to be called. Any suggestions?
Thanks.
FF: 26
I have this custom CanvasItem that I'd like to have validate when form.validate() is called. I tried overloading validate (see below), but it doesn't seem to be called. Any suggestions?
Thanks.
Code:
private static class DelayTimeItem extends CanvasItem{ private IntegerItem daysField; private TimeItem timeField; private DynamicForm form; public DelayTimeItem(String name, String title){ super(name, title); final ChangedHandler handler = new ChangedHandler(){ @Override public void onChanged(ChangedEvent event) { if(daysField.getValue() instanceof Integer && timeField.getValue() instanceof Date){ storeValue(convertValue()); } } private long convertValue() { long minutes = 0; Integer days = (Integer) daysField.getValue(); Date time = (Date) timeField.getValue(); if(days != null) { minutes += days * 24 * 60; } if(time != null) { minutes = time.getHours() * 60 + time.getMinutes(); } return minutes; } }; daysField = new IntegerItem("days"){{ setWidth(48); setShowTitle(false); addChangedHandler(handler); }}; timeField = new TimeItem("time"){{ setWidth(64); setShowTitle(false); addChangedHandler(handler); }}; form = new DynamicForm(){{ setFields(daysField, new StaticTextItem(){{ setShowTitle(false); setContents("days"); }}, timeField); setNumCols(3); }}; setCanvas(form); addShowValueHandler(new ShowValueHandler() { @Override public void onShowValue(ShowValueEvent event) { Integer value = (Integer) event.getDataValue(); if(value != null){ long days = value / (24 * 60); long minutes = value % (24 * 60); daysField.setValue(days); timeField.setValue(minutes / 60 + ":" + minutes % 60); } } }); } @Override public Boolean validate() { return super.validate() && daysField.validate() && timeField.validate(); } }
Comment