1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    22
    Vote Rating
    0
    hbrands is on a distinguished road

      0  

    Default [FIXED] FormBinding issue with ComboBox

    [FIXED] FormBinding issue with ComboBox


    I have a situation where the selected combobox value is not committed to the
    bound property of a source bean.

    Attached is an example that demonstrates the issue.
    Class MyBean has a property 'value' of type 'MyValue' that is bound to a ComboBox.
    If I select a value by mouse from the drop down list of the ComboBox, the value is committed correctly to the bean, as shown by the log message in the bean setter method.

    If I begin to type a value into the text field of the ComboBox and autocomplete the
    value by using the TAB-key or by using ENTER and then the TAB-key, the value is
    not committed to the bean.

    Is this a bug or a problem in my code?

    (I want the ComboBox to be editable with type-ahead-filter active, but allowed values
    are restricted to the ListStore values. The user should be able to select a value this way without the mouse)

    Thanks,
    Holger

    P.S.: I'm using GXT 1.2.3 on Windows XP in hosted modus and web modus with Firefox 3.0.6.

    Code:
    public class ComboBoxBug implements EntryPoint {
    
        private static NumberConstants NUMBER_CONSTANTS;
    
        private final LayoutContainer contentContainerPanel = new LayoutContainer();
    
        private Widget content;
    
        private final Viewport viewport = new Viewport();
    
        public void onModuleLoad() {
            ThemeManager.register(Slate.SLATE);
            contentContainerPanel.setLayout(new FitLayout());
            viewport.setLayout(new BorderLayout());
            final BorderLayoutData westLayoutData = new BorderLayoutData(LayoutRegion.WEST, 200);
            westLayoutData.setMargins(new Margins(5));
            westLayoutData.setSplit(true);
            westLayoutData.setCollapsible(true);
            final BorderLayoutData centerLayoutData = new BorderLayoutData(LayoutRegion.CENTER);
            centerLayoutData.setMargins(new Margins(5, 5, 5, 0));
            viewport.add(contentContainerPanel, centerLayoutData);
            final BorderLayoutData northLayoutData = new BorderLayoutData(LayoutRegion.NORTH, 33);
            northLayoutData.setMargins(new Margins());
            RootPanel.get().add(viewport);
            NUMBER_CONSTANTS = (NumberConstants) GWT.create(NumberConstants.class);
            final Widget initialContent = createInitialContent();
            setContent(initialContent);
            GWT.log("groupingSeparator=" + NUMBER_CONSTANTS.groupingSeparator(), null);
            GWT.log("decimalSeparator=" + NUMBER_CONSTANTS.decimalSeparator(), null);
        }
    
        private Widget createInitialContent() {
            BeanModelFactory factory = BeanModelLookup.get().getFactory(MyBean.class);
            final MyBean data = new MyBean();
            data.setComment("Test");
            BeanModel beanModel = factory.createModel(data);
            final FormPanel result = new FormPanel();
            result.setFrame(true);
            result.setHeaderVisible(false);
            result.setBodyBorder(false);
            result.setBorders(false);
            result.setLabelWidth(120);
            result.setLabelAlign(LabelAlign.TOP);
            result.setSize(250, 450);
    
            final ComboBox<BeanModel> valueField = new ComboBox<BeanModel>();
            valueField.setMinChars(1);
            valueField.setStore(createListStore());
            valueField.setDisplayField("name");
            valueField.setAllowBlank(false);
            valueField.setTypeAhead(true);
            valueField.setSelectOnFocus(true);
            valueField.setEditable(true);
            valueField.setForceSelection(true);
            valueField.setTriggerAction(TriggerAction.ALL);
            valueField.setName("value");
            valueField.setFieldLabel("Value");
            result.add(valueField);
            final TextField<String> commentField = new TextField<String>();
            commentField.setSelectOnFocus(true);
            commentField.setAutoValidate(true);
            commentField.setName("comment");
            commentField.setFieldLabel("Comment");
            result.add(commentField);
            final FormBinding binding = new FormBinding(result, true);
            binding.bind(beanModel);
            return result;
        }
    
        private void setContent(Widget newContent) {
            if (content != null) {
                contentContainerPanel.remove(content);
                content = null;
            }
            contentContainerPanel.add(newContent);
            content = newContent;
            contentContainerPanel.layout();
            contentContainerPanel.show();
        }
    
        private ListStore<BeanModel> createListStore() {
            final List<MyValue> values = new ArrayList<MyValue>();
            values.add(new MyValue("A value"));
            values.add(new MyValue("B value"));
            values.add(new MyValue("C value"));
    
            final BeanModelFactory factory = BeanModelLookup.get().getFactory(MyValue.class);
            final List<BeanModel> valueModels = factory.createModel(values);
            final ListStore<BeanModel> result = new ListStore<BeanModel>();
            result.add(valueModels);
            return result;
        }
    
        public static class MyBean implements BeanModelTag, Serializable {
            private MyValue value;
    
            private String comment;
    
            public MyValue getValue() {
                return value;
            }
    
            public void setValue(MyValue value) {
                GWT.log("MyBean.setValue: " + value, null);
                this.value = value;
            }
    
            public String getComment() {
                return comment;
            }
    
            public void setComment(String comment) {
                this.comment = comment;
            }
        }
    
        public static class MyValue implements BeanModelTag, Serializable {
            private String name;
    
            public MyValue(String name) {
                this.name = name;
            }
    
            public String getName() {
                return name;
            }
    
            public void setComment(String name) {
                this.name = name;
            }
    
            @Override
            public String toString() {
                return name;
            }
        }
    
    }

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    This is a duplicate report. Please use the search before opening new bug reports.

  3. #3
    Ext User
    Join Date
    Oct 2008
    Posts
    22
    Vote Rating
    0
    hbrands is on a distinguished road

      0  

    Default


    You're right.
    I found this thread:
    http://www.extjs.com/forum/showthread.php?t=60243
    But it's marked as fixed and commented as fixed for 1.2.3.
    The last comment in that thread indicates,
    that it's not fixed in 1.2.3, a confirmation pending...
    So, take the time I invested in making this test case as
    a friendly reminder for this issue ;-)

    Thanks,
    Holger

  4. #4
    Sencha User
    Join Date
    Mar 2009
    Location
    Denver, CO
    Posts
    38
    Vote Rating
    0
    mabco is on a distinguished road

      0  

    Default


    I would also like to know when this is going to be fixed. Could we get an answer? It's definitely not fixed in 1.2.3; I just tested it. (Thanks, Holger, for the example code.).

  5. #5
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    With 1.2.4.

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Fixed in SVN.

Thread Participants: 2