Announcement

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

    ComboBoxItem with EmptyDisplayValue returns incorrect empty value

    SmartGwt 2.5 - ie9 (and propably all)

    When EmptyDisplayValue is set and field is empty (null), the getValue() method returns the value of the EmptyDisplayValue, not null.

    It affects the validate method of the ValuesManager, when EmptyDisplayValue used in a required field, on validation no error reported.

    FormItem.getValue() - returns bad value
    ValuesManager.getValue(String fieldName) - returns bad value

    ValuesManager.getItem(String itemID).getValue() - returns correct value
    I use this as workaround when getting data from the form, but can't handle the validation method.

    #2
    Can you show code that would allow this to be reproduced?

    Comment


      #3
      Originally posted by Isomorphic
      Can you show code that would allow this to be reproduced?
      With this code, the described problem came on the _second_ click of the test button. All three methods read the incorrect value second time, and validation "fails" too. (If i erase the displayvalue, then for the first time it works well again...)

      Code:
      class TestLayout extends HLayout {
        public TestLayout() {
      
          final ValuesManager vm = new ValuesManager();
      
          final DynamicForm form = new DynamicForm();
          form.setValuesManager(vm);
      
          final ComboBoxItem comboBox = new ComboBoxItem("fieldName");
          comboBox.setRequired(true);
          comboBox.setValueMap("a1", "a1");
          comboBox.setEmptyDisplayValue("alma");
      
          ButtonItem button = new ButtonItem("test");
          button.addClickHandler(new ClickHandler() {
      
            @Override
            public void onClick(ClickEvent event) {
              StringBuilder sb = new StringBuilder();
              sb.append("ValuesManager.getValue() = " + vm.getValue("fieldName")).append("<br />");
              sb.append("ValuesManager.getItem(itemId).getValue() = ").append(vm.getItem("fieldName").getValue()).append("<br />");
              sb.append("ComboBoxItem.getValue() = ").append(comboBox.getValue()).append("<br />");
              sb.append("ValuesManager.validate() = ").append(vm.validate()).append("<br />");
              SC.say(sb.toString());
            }
          });
      
          form.setItems(comboBox, button);
          addMember(form);
        }
      }
      Last edited by plajko; 18 Nov 2011, 10:09.

      Comment


        #4
        This looks like it may be a fixed bug. Can you try this with the latest 2.5.x nightly from SmartClient.com/builds to confirm?

        Comment


          #5
          Originally posted by Isomorphic
          This looks like it may be a fixed bug. Can you try this with the latest 2.5.x nightly from SmartClient.com/builds to confirm?
          A tried it just now with this build:

          http://www.smartclient.com/builds/SmartGWT/2.x/LGPL/2011-11-21

          Problem still exist in this one.

          Comment


            #6
            Thanks for the report - we've fixed this and the fix will appear in upcoming nightlies

            Comment


              #7
              We are using 4.0 and still seeing this problem...

              Seems like the input elements placeholder attribute would be a much better implementation, where appropriate, than whatever weirdness is going on.

              BTW this is with IE10.
              Last edited by tuckerpm; 19 Sep 2013, 05:13. Reason: Add browser verison

              Comment


                #8
                We show this as fixed using the test case above. If you can reproduce the issue with some other test case, please post that test case.

                Comment


                  #9
                  My case uses a restdatasource in place of a value map. Do you have a unit test in place for this? I'm not sure how I can provide you with a working example without a rest service that you can hit.

                  Comment


                    #10
                    Yes, we do have such a test.

                    You can use a clientOnly DataSource to attempt to create a test case.

                    If you can't replicate the problem with a clientOnly DataSource, then the problem is likely that something is wrong with your DataSource, not the ComboBoxItem's emptyDisplayValue behavior as such.

                    Comment


                      #11
                      Ok, I'll get back to you when I have a sample or a solution.

                      Thank!

                      Comment


                        #12
                        I was able to reproduce it with the following code:
                        Code:
                           public void onModuleLoad () {
                        
                              RestDataSource dataSource = new RestDataSource();
                              dataSource.setClientOnly(true);
                        
                              ComboBoxItem comboBoxItem = new ComboBoxItem("Facility");
                              comboBoxItem.setAutoFetchData(true);
                              comboBoxItem.setEmptyDisplayValue("-- Select a Facility --");
                              comboBoxItem.setOptionDataSource(dataSource);
                              comboBoxItem.addChangedHandler(new ChangedHandler() {
                                @Override
                                public void onChanged(ChangedEvent event) {
                                    System.out.println("Event Value=" + event.getValue());
                                }
                              });
                        
                              DynamicForm dynamicForm = new DynamicForm();
                              dynamicForm.setWidth(300);
                              dynamicForm.setItems(comboBoxItem);
                        
                              dynamicForm.draw();
                           }
                        The output:
                        Code:
                        Event Value=-- Select a Facility --
                        Event Value=null

                        Comment


                          #13
                          Isomorphic,

                          Can you provide any feedback?

                          Comment


                            #14
                            I would greatly appreciate some kind of feedback.

                            Comment


                              #15
                              We've made a change to address this - please retest with a nightly build dated October 11 or later

                              Comment

                              Working...
                              X