SmartGWT 2.3
I have a series of DateItem on a DynamicForm and I see that the onChange and onChanged (on SmartGWTEE) event seems to triggered too many times.
Also some problem with onBlur and onFocus event.
Attached, I put my test result.
Here is a sample code that I use just to see which event got triggered for each action that I do on a DateItem.
I have a series of DateItem on a DynamicForm and I see that the onChange and onChanged (on SmartGWTEE) event seems to triggered too many times.
Also some problem with onBlur and onFocus event.
Attached, I put my test result.
Here is a sample code that I use just to see which event got triggered for each action that I do on a DateItem.
Code:
package test.example.client; import java.util.ArrayList; import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.DateItem; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; import com.smartgwt.client.widgets.form.fields.events.FocusEvent; import com.smartgwt.client.widgets.form.fields.events.FocusHandler; import com.smartgwt.client.widgets.form.fields.events.IconClickEvent; import com.smartgwt.client.widgets.form.fields.events.IconClickHandler; import com.smartgwt.client.widgets.form.fields.events.IconKeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.IconKeyPressHandler; import com.smartgwt.client.widgets.form.fields.events.KeyDownEvent; import com.smartgwt.client.widgets.form.fields.events.KeyDownHandler; import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent; import com.smartgwt.client.widgets.form.fields.events.KeyUpHandler; public class TestDateItemEvent implements EntryPoint { DynamicForm testDateForm = new DynamicForm(); @Override public void onModuleLoad() { // TODO Auto-generated method stub ArrayList<FormItem> formFields = new ArrayList<FormItem>(); DateItem dateItem1 = new DateItem("DATE1"); dateItem1.setAttribute("changeOnKeyPress", false); dateItem1.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { printMessage(event.getItem().getFieldName(), "onKeyDown"); } }); dateItem1.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onKeyPress"); } }); dateItem1.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { printMessage(event.getItem().getFieldName(), "onKeyUp"); } }); dateItem1.addIconClickHandler(new IconClickHandler() { @Override public void onIconClick(IconClickEvent event) { printMessage(event.getItem().getFieldName(), "onIconClick"); } }); dateItem1.addIconKeyPressHandler(new IconKeyPressHandler() { @Override public void onIconKeyPress(IconKeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onIconKeyPress"); } }); dateItem1.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { printMessage(event.getItem().getFieldName(), "onBlur"); } }); dateItem1.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { printMessage(event.getItem().getFieldName(), "onChanged"); } }); dateItem1.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { printMessage(event.getItem().getFieldName(), "onChange"); } }); dateItem1.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { printMessage(event.getItem().getFieldName(), "onClick"); } }); dateItem1.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { printMessage(event.getItem().getFieldName(), "onFocus"); } }); formFields.add(dateItem1); DateItem dateItem2 = new DateItem("DATE2"); dateItem2.setAttribute("changeOnKeyPress", false); dateItem2.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { printMessage(event.getItem().getFieldName(), "onKeyDown"); } }); dateItem2.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onKeyPress"); } }); dateItem2.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { printMessage(event.getItem().getFieldName(), "onKeyUp"); } }); dateItem2.addIconClickHandler(new IconClickHandler() { @Override public void onIconClick(IconClickEvent event) { printMessage(event.getItem().getFieldName(), "onIconClick"); } }); dateItem2.addIconKeyPressHandler(new IconKeyPressHandler() { @Override public void onIconKeyPress(IconKeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onIconKeyPress"); } }); dateItem2.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { printMessage(event.getItem().getFieldName(), "onBlur"); } }); dateItem2.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { printMessage(event.getItem().getFieldName(), "onChanged"); } }); dateItem2.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { printMessage(event.getItem().getFieldName(), "onChange"); } }); dateItem2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { printMessage(event.getItem().getFieldName(), "onClick"); } }); dateItem2.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { printMessage(event.getItem().getFieldName(), "onFocus"); } }); formFields.add(dateItem2); TextItem textItem1 = new TextItem("TEXT1"); textItem1.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { printMessage(event.getItem().getFieldName(), "onKeyDown"); } }); textItem1.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onKeyPress"); } }); textItem1.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { printMessage(event.getItem().getFieldName(), "onKeyUp"); } }); textItem1.addIconClickHandler(new IconClickHandler() { @Override public void onIconClick(IconClickEvent event) { printMessage(event.getItem().getFieldName(), "onIconClick"); } }); textItem1.addIconKeyPressHandler(new IconKeyPressHandler() { @Override public void onIconKeyPress(IconKeyPressEvent event) { printMessage(event.getItem().getFieldName(), "onIconKeyPress"); } }); textItem1.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { printMessage(event.getItem().getFieldName(), "onBlur"); } }); textItem1.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { printMessage(event.getItem().getFieldName(), "onChanged"); } }); textItem1.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { printMessage(event.getItem().getFieldName(), "onChange"); } }); textItem1.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { printMessage(event.getItem().getFieldName(), "onClick"); } }); textItem1.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { printMessage(event.getItem().getFieldName(), "onFocus"); } }); formFields.add(textItem1); FormItem[] formFieldsArray = new FormItem[formFields.size()]; formFieldsArray = formFields.toArray(formFieldsArray); testDateForm.setNumCols(4); testDateForm.setFields(formFieldsArray); testDateForm.show(); } private void printMessage(String fieldName, String eventName) { Date eventDate = new Date(); System.out.println(fieldName + ": " + eventName + " fired " + eventDate.toString()); } }
Comment