nijogeorgep / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

Setting setValueMap of a ComboBoxItem inside Calendar has not effect when called from key up event. #587

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Environment
- Smart GWT Version: 2.4 nightly build
- GWT Version: 2.2.0
- Browser: Firefox 3.6.17, Chrome 11.0.696.65, Safari 5.0
- OS: Mac OS

Test case:

public class SampleModule implements EntryPoint {

    public void onModuleLoad() {
        Calendar calendar = new Calendar();
        final ComboBoxItem item = new ComboBoxItem();
        item.setName("customName");
        item.setTitle("Custom name");

        LinkedHashMap map = new LinkedHashMap();
        map.put("1", "2");
        map.put("3", "4");
        item.setValueMap(map);

        item.addKeyUpHandler(new KeyUpHandler() {
            public void onKeyUp(KeyUpEvent event) {
                changeValues(item);
            }

            private void changeValues(ComboBoxItem item) {
                LinkedHashMap map = new LinkedHashMap();
                map.put("A", "B");
                map.put("C", "D");
                item.setValueMap(map);              
            }
        });

        calendar.setEventDialogFields(item);
        calendar.draw();
    }
}

Expected result:
- The values in the ComboBoxItem are updated after a key press. They are NOT 
updated after the key press.

Possible problem:
I found that the calendar is shallow copying the fields (I guess this should 
not be done in this way). Line 2735 of Calendar.js inside "createFields"
From a developer perspective, I expect that the object I'm setting as a field 
is the same used in the UI. So if I set both setEventDialogFields and 
setEventEditorFields I may have to pass 2 different UI instances.

Original issue reported on code.google.com by esteban....@gmail.com on 16 May 2011 at 2:15

GoogleCodeExporter commented 8 years ago
You don't know, at KeyUp, whether you've got a Tab, Enter or other special 
keypress going on.  So this looks like a bad approach for a use case already 
better handled by optionDataSource.

Original comment by smartgwt...@gmail.com on 16 May 2011 at 5:25