1. #1
    Ext User andrey's Avatar
    Join Date
    May 2008
    Location
    Boston
    Posts
    34
    Vote Rating
    0
    andrey is on a distinguished road

      0  

    Default [FIXED] Beta4 CheckBox change event not working

    [FIXED] Beta4 CheckBox change event not working


    The CheckBox change event is not calling back the listener with Beta4:
    Code:
    import com.extjs.gxt.ui.client.Events;
    import com.extjs.gxt.ui.client.event.BaseEvent;
    import com.extjs.gxt.ui.client.event.Listener;
    import com.extjs.gxt.ui.client.widget.Info;
    import com.extjs.gxt.ui.client.widget.Viewport;
    import com.extjs.gxt.ui.client.widget.form.CheckBox;
    import com.extjs.gxt.ui.client.widget.layout.FillLayout;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.ui.RootPanel;
    
    public class TestCheckBox implements EntryPoint {
        public void onModuleLoad() {
            Viewport viewport = new Viewport();
            viewport.setLayout(new FillLayout());
            
            CheckBox cb = new CheckBox();
            
            viewport.add(cb);
            cb.addListener(Events.Change, new Listener<BaseEvent>() {
                public void handleEvent(BaseEvent be) {
                    GWT.log("CheckBox change", null);            // Not being called in Beta4
                    Info.display("Debug", "CheckBox change");
                }
            });
            viewport.layout();
            RootPanel.get("slot1").add(viewport);
        }
    }
    Run the above code and check/un-check the CheckBox and notice no Info or GWT log.

    Thx,
    Andre

  2. #2
    Ext User
    Join Date
    Apr 2008
    Location
    Munich, Germany
    Posts
    43
    Vote Rating
    0
    flow is on a distinguished road

      0  

    Default


    Hi Andre,

    have you tried the Event.ONCLICK instead of the Event.Change?
    Cheers,
    Flo~

  3. #3
    Ext User
    Join Date
    May 2008
    Posts
    105
    Vote Rating
    0
    Grandiosa is on a distinguished road

      0  

    Default


    Yep, the OnClick will make it work, but that contradicts the Javadoc for CheckBox.

    Here is what I have found (see attached example program)

    1. A CheckBox's listener is not triggered on Change events as specified in its Javadoc. However, OnClick events work.

    2. Radio listeners can be triggered using either Change and OnClick events.

    3. Using OnClick events the Radio's listener is triggered when the radio is clicked, regardless of its previous state.

    4. Using Change events, the Radio's listener is triggered both when a Radio is deselected and selected.


    Code:
    public class Main implements EntryPoint {
    
        public void onModuleLoad() {
    
            Viewport vp = new Viewport();
            vp.setLayout(new FitLayout());
    
            ContentPanel panel = new ContentPanel(new CenterLayout());
    
            FormPanel form = new FormPanel();
            form.setFieldWidth(210);
            form.setWidth(380);
    
            CheckBox cb1 = new CheckBox();
            cb1.setFieldLabel("Doesn't fire");
            cb1.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    Info.display("Info", "Checkbox1 triggered");
                }
            });
    
            form.add(cb1);
    
            CheckBox cb2 = new CheckBox();
            cb2.setFieldLabel("Fires ok");
            cb2.addListener(Events.OnClick, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    Info.display("Info", "Checkbox2 triggered");
                }
            });
            form.add(cb2);
    
            
            final Radio radio1 = new Radio();
            radio1.setName("radio1");
            radio1.setFieldLabel("First");
            radio1.setValue(true);
            radio1.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio1", "Change event");
                }
            });
            radio1.addListener(Events.OnClick, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio1", "OnClick event");
                }
            });
    
            final Radio radio2 = new Radio();
            radio2.setName("radio2");
            radio2.setFieldLabel("Second");
            radio2.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio2", "Change event");
                }
            });
    
            RadioGroup radioGroup = new RadioGroup("Whatever");
            radioGroup.setFieldLabel("Order");
            radioGroup.add(radio1);
            radioGroup.add(radio2);
            form.add(radioGroup);
            panel.add(form);
    
            vp.add(panel);
            vp.layout();
            RootPanel.get().add(vp);
        }
    }

  4. #4
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    Fix is in SVN. Please validate.

  5. #5
    Ext User
    Join Date
    May 2008
    Posts
    105
    Vote Rating
    0
    Grandiosa is on a distinguished road

      0  

    Default


    Darrel,

    Now the CheckBoxes work ok, but the Radio listeners are "messed" up.
    Using the example program below shows that:

    - Radio1 listener is called on program startup, which is ok I guess even if the listener was actually added after the Radio is set programmatically using setValue() in the program.

    - Clicking Radio2 fires ChangeEvent listener of Radio1. Clicking Radio3 fires listener of Radio2, ...

    - Using OnClick events however works ok for both Radios and CheckBoxes.

    I tried debugging your code but got lost somwhere between method calls

    But the first line in Field.fireChangeEvent(Object oldValue, Object newValue) looks wrong to me:

    if (oldValue != value) {

    I guess should use equals instead?


    example program:

    Code:
        public void onModuleLoad() {
    
            Viewport vp = new Viewport();
            vp.setLayout(new FitLayout());
    
            ContentPanel panel = new ContentPanel(new CenterLayout());
    
            FormPanel form = new FormPanel();
            form.setFieldWidth(210);
            form.setWidth(380);
    
            // checkbox using Change event listener
            CheckBox cb1 = new CheckBox();
            cb1.setFieldLabel("Box1");
            cb1.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    Info.display("Info", "Checkbox1 triggered");
                }
            });
    
            form.add(cb1);
    
            // using OnClick listener also works
            CheckBox cb2 = new CheckBox();
            cb2.setFieldLabel("Box2");
            cb2.addListener(Events.OnClick, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent fe) {
                    Info.display("Info", "Checkbox2 triggered");
                }
            });
            form.add(cb2);
    
    
            final Radio radio1 = new Radio();
            radio1.setName("radio1");
            radio1.setFieldLabel("First");
            radio1.setValue(true);
            radio1.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio1", "Change event");
                }
            });
    
            final Radio radio2 = new Radio();
            radio2.setName("radio2");
            radio2.setFieldLabel("Second");
            radio2.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio2", "Change event");
                }
            });
    
            final Radio radio3 = new Radio();
            radio3.setName("radio3");
            radio3.setFieldLabel("Third");
            radio3.addListener(Events.Change, new Listener<FieldEvent>() {
                public void handleEvent(FieldEvent be) {
                    Info.display("Radio3", "Change event");
                }
            });
    
            
            RadioGroup radioGroup = new RadioGroup("Whatever");
            radioGroup.setFieldLabel("Order");
            radioGroup.add(radio1);
            radioGroup.add(radio2);
            radioGroup.add(radio3);
            form.add(radioGroup);
            panel.add(form);
    
            vp.add(panel);
            vp.layout();
            RootPanel.get().add(vp);
        }

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi