Announcement

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

    Bug report (test case included): IE 11, 4.0p: Emptying FormItem not seen as a change

    Hi,

    this is now the bug report that prevents us from going back to 4.1p (see my other post from today http://forums.smartclient.com/showthread.php?t=32065).

    Affected environment
    * 4.1p latest nightlies (2015-01-10)
    * IE 11.0.9600.17501

    The bug disappears when using on of these browsers
    * Firefox 34 on Windows
    * Chromium on Ubuntu
    * IE 8 emulated mode from IE 11.0.9600.17501

    The bug is also not reproducable
    * SmartGwt 5.0p latest nightly (2015-0-10) EDIT: I just noticed an internal bug report ticket where one of our testers has seen this in 5.0p and IE11, too. But I cannot reproduce it. When you find the reason for this bug and fix it in 4.1p you should have a look at 5.0p, too.

    The core problem is that a TextItem (and maybe other FormItems) are reporting themselves as unchanged when the formitem is emptied.

    The attached test case shows this.

    Steps to reproduce:
    * DataSourceA as a source for the DynamicForm with
    - DataSourceTextField for TextItem-FormItem
    * DynamicForm with
    - Attached to DataSourceA
    - TextItem attached to DataSourceTextField
    - Attached to ValuesManager
    * ValuesManager attached to DataSourceA and DynamicForm
    * Button
    - valuesManager.validate()
    - GWT.log(valuesManager.getChangedValues().toString());
    - valuesManager.saveData();
    * Start app
    * Enter a single character in the text field
    * Hit Save Button
    - Note that getChangedValues logs that both attributes got changed
    * Empty the TextItem (by selecting the text and hitting backspace, or any other way)
    * Hit Save Button
    - valuesManager.getChangedValues().size() is 0!!!!

    Additionally info: An ItemChangedHandler will also not fire when the formItem is emptied.

    Regards,
    Andre
    Attached Files
    Last edited by SCAI_Andre; 11 Jan 2015, 06:11. Reason: Correction for version

    #2
    gwt.xml

    and here goes the gwt.xml

    See my other thread for details on the test project template we use.
    Attached Files

    Comment


      #3
      Added also as a comment to the initial post in this thread: I just noticed an internal bug report ticket where one of our testers has seen this in 5.0p and IE11, too. But I cannot reproduce it. When you find the reason for this bug and fix it in 4.1p you should have a look at 5.0p, too.

      Comment


        #4
        Forgot: The problem occurs in the LGPL version

        Comment


          #5
          Simplified test case for this one, too.

          Although I think that http://forums.smartclient.com/showthread.php?t=32065 is far more disturbing. I added a single class test case there, too. So please also have a look there.

          Code:
          package de.scai.client.ticket1449.defect;
          
          import com.google.gwt.core.client.EntryPoint;
          import com.google.gwt.core.client.GWT;
          import com.google.gwt.user.client.ui.RootPanel;
          import com.smartgwt.client.data.DSCallback;
          import com.smartgwt.client.data.DSRequest;
          import com.smartgwt.client.data.DSResponse;
          import com.smartgwt.client.data.DataSource;
          import com.smartgwt.client.data.fields.DataSourceIntegerField;
          import com.smartgwt.client.data.fields.DataSourceTextField;
          import com.smartgwt.client.util.SC;
          import com.smartgwt.client.widgets.Button;
          import com.smartgwt.client.widgets.events.ClickEvent;
          import com.smartgwt.client.widgets.events.ClickHandler;
          import com.smartgwt.client.widgets.form.DynamicForm;
          import com.smartgwt.client.widgets.form.ValuesManager;
          import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
          import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
          import com.smartgwt.client.widgets.form.fields.TextItem;
          import com.smartgwt.client.widgets.layout.Layout;
          import com.smartgwt.client.widgets.layout.VLayout;
          
          public class DemoTicket1449 implements EntryPoint {
          
              private Layout layoutRoot;
          
              /**
               * This is the entry point method.
               */
              public void onModuleLoad() {
                  layoutRoot = new VLayout();
          
                  RootPanel.get("gwtContainer").add(layoutRoot);
          
                  run();
              }
          
              private class UserDataSource extends DataSource {
                  public static final String FIELDNAME_ID = "FIELD_id";
                  public static final String FIELDNAME_USERNAME = "FIELD_userName";
          
                  protected DataSourceIntegerField id = new DataSourceIntegerField(FIELDNAME_ID, "Id");
                  protected DataSourceTextField userName = new DataSourceTextField(FIELDNAME_USERNAME, "Username");
          
                  private UserDataSource() {
                      super();
                      id.setPrimaryKey(true);
                      addField(id);
                      addField(userName);
                      setClientOnly(true);
                      setCacheAllData(true);
                  }
          
              }
          
              private class UserDynamicForm extends DynamicForm {
                  protected TextItem userName = new TextItem(UserDataSource.FIELDNAME_USERNAME, "Username");
          
                  protected void init() {
          
                      this.setFields(
                              userName
                      );
                  }
              }
          
              private UserDataSource userDataSource;
              private ValuesManager valuesManager;
              private UserDynamicForm userDynamicForm;
              private Button save;
          
              public void run() {
          
                  userDataSource = new UserDataSource();
          
                  valuesManager = new ValuesManager();
                  valuesManager.setDataSource(userDataSource);
          
                  initForm();
          
                  Layout layout = new VLayout();
                  layout.addMember(userDynamicForm);
                  layoutRoot.addMember(layout);
          
                  save = new Button("Save");
                  save.addClickHandler(new ClickHandler() {
                      @Override
                      public void onClick(ClickEvent clickEvent) {
                          if (valuesManager.validate()) {
                              GWT.log(valuesManager.getChangedValues().toString());
                              if (valuesManager.getChangedValues().size() == 0) {
                                  SC.warn("No changed values");
                              }
                              valuesManager.saveData(new DSCallback() {
                                  @Override
                                  public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                                      GWT.log("dsResponse.result is: " + Integer.toString(dsResponse.getStatus()));
                                  }
                              });
                          }
                      }
                  });
                  layout.addMember(save);
          
          
                  userDynamicForm.addItemChangedHandler(new ItemChangedHandler() {
                      @Override
                      public void onItemChanged(ItemChangedEvent event) {
                          GWT.log(valuesManager.getChangedValues().toString());
                      }
                  });
          
                  valuesManager.addMember(userDynamicForm);
                  valuesManager.editNewRecord();
              }
          
              private void initForm() {
                  userDynamicForm = new UserDynamicForm();
                  userDynamicForm.init();
                  userDynamicForm.setDataSource(userDataSource);
              }
          
          }

          Comment


            #6
            Thanks for the simplified test case, that helps a lot. This is now fixed for 9.1 and up for tomorrow's nightly patch builds. This may have the same underlying root cause as the other bug you reported, we'll know soon.

            Comment


              #7
              Hi,

              using this build: https://smartclient.com/builds/SmartGWT/4.1p/LGPL/2015-01-13/

              Fix confirmed!

              Hopefully you can find the cause for the other bug, too!

              Thank you!

              Regards,
              Andre

              Comment

              Working...
              X