Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicForm.reset changes item value but does not fire item's ChangedHandlers

    In the test program below a DynamicForm has a "Reset" ButtonItem whose ClickHandler calls DynamicForm.reset() to reset the values of the form. The form also has a CheckboxItem enableDemoModeItem with a ChangedHandler.

    I am finding that the Changed Handler on enableDemoModeItem does not get called when the value of of the field is changed (reset) by clicking the Reset button. I expected that the Changed Handler wouldbe called.

    Is this an issue that should be fixed?

    Code:
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.CheckboxItem;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    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.layout.VLayout;
    
    public class GUIApp implements EntryPoint {
        public void onModuleLoad() {
            Canvas canvas = new MyCanvas();
            RootPanel.get().add(canvas);
        }
    
        public class MyCanvas extends VLayout {
    
            DynamicForm form;
            CheckboxItem enableDemoModeItem;
    
            public MyCanvas() {
                form = new DynamicForm();
                form.setNumCols(2);
    
                enableDemoModeItem = new CheckboxItem("Enable Demo Mode");
                enableDemoModeItem.addChangedHandler(new ChangedHandler() {
                    public void onChanged(ChangedEvent event) {
                        SC.say("value changed");
                    }
                });
    
                ButtonItem resetButton = new ButtonItem("Reset to Default Values");
                resetButton.addClickHandler(new ClickHandler() {
    
                    public void onClick(ClickEvent event) {
                        resetAction();
                    }
                });
    
                form.setFields(new FormItem[]{enableDemoModeItem, resetButton});
                form.setWidth100();
                //form.setHeight100();
                this.addMember(form);
            }
    
            private void resetAction() {
                form.reset();
            }
        }
    }

    #2
    By design, for the same reason as your other question on setValue() and changed().

    Comment

    Working...
    X