Announcement

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

    ComboBoxItem issue with missing fetchMissingValueReply (when used as ListGrid editor only?)

    Hi Isomorphic,

    creating this testcase I noticed there is an issue with ComboBoxItems used as editor in ListGridFields. It seems in that case they don't fire the necessary fetchMissingValueReply needed for the displayField. This is not true for SelectItems (on open fetchRemoteDataReply to load the pickList rows 0-75) and also works in normal DynamicForms where there is the fetchMissingValueReply-request.
    I can also reproduce the issue in my application, but as I'm not having that setting often, I did not notice this, yet.

    Please see this video (v11.1p_2018-01-18):
    Click image for larger version

Name:	ComboBoxItem problem with missing fetchMissingValuesReply.gif
Views:	311
Size:	100.4 KB
ID:	251398
    Until you open the pickList, the displayField value is missing for all rows, after you opened the pickList once, it is present for all rows.

    (I did not test what happens if the fetchRemoteDataReply if either the ComboBoxItem or the SelectItem does not include the needed row, yet, but will do so next.)


    Change to the linked testcase:
    Code:
            if (asSelectItem) {
                SelectItem si = new SelectItem("ID");
                si.setCachePickListResults(false);
                si.setOptionDataSource(DataSource.get("COMPANY"));
                si.setValueField("ID");
                si.setDisplayField("[B]NAMETWICE[/B]");
                companyIdLGF.setEditorProperties(si);
            } else {
                ComboBoxItem cbi = new ComboBoxItem("ID");
                cbi.setCachePickListResults(false);
                cbi.setOptionDataSource(DataSource.get("COMPANY"));
                cbi.setValueField("ID");
                cbi.setDisplayField("[B]NAMETWICE[/B]");
                companyIdLGF.setEditorProperties(cbi);
            }
    Best regards
    Blama

    #2
    Hi Isomorphic,

    OK, this does also happen for SelectItems when the needed data is not in the first 75 rows for the pickList fetchRemoteDataReply (still v11.1p_2018-01-18).

    Please see this change to the testcase:
    Code:
            if (asSelectItem) {
                SelectItem si = new SelectItem("ID");
                si.setCachePickListResults(false);
                si.setOptionDataSource(DataSource.get("COMPANY"));
                si.setValueField("ID");
                si.setDisplayField("[B]NAMETWICE[/B]");
    [B]si.setSortField("NAMETWICE");[/B]
                companyIdLGF.setEditorProperties(si);
            } else {
                ComboBoxItem cbi = new ComboBoxItem("ID");
                cbi.setCachePickListResults(false);
                cbi.setOptionDataSource(DataSource.get("COMPANY"));
                cbi.setValueField("ID");
                cbi.setDisplayField("[B]NAMETWICE[/B]");
    [B]cbi.setSortField("NAMETWICE");[/B]
                companyIdLGF.setEditorProperties(cbi);
            }
    Data generation DML change:
    Code:
    [B]INSERT INTO company (ID,NAME)
    SELECT level, 'Company ' || to_char(level, '000') FROM dual connect by level<=400;[/B]
    
    INSERT INTO reseller (ID,company_id,NAME) VALUES (1,1,'Reseller 1');
    INSERT INTO reseller (ID,company_id,NAME) VALUES (2,[B]100[/B],'Reseller 2');
    INSERT INTO reseller (ID,company_id,NAME) VALUES (3,[B]400[/B],'Reseller 3');
    Best regards
    Blama

    Comment


      #3
      Hi Isomorphic,

      as this touches the same area as the linked thread in #1, this also happens with this code:
      Code:
              if (asSelectItem) {
                  SelectItem si = new SelectItem("ID");
                  si.setCachePickListResults(false);
                  si.setOptionDataSource(DataSource.get("COMPANY"));
                  si.setValueField("ID");
                  si.set[B]Foreign[/B]DisplayField("NAMETWICE");
                  si.setSortField("NAMETWICE");
                  companyIdLGF.setEditorProperties(si);
              } else {
                  ComboBoxItem cbi = new ComboBoxItem("ID");
                  cbi.setCachePickListResults(false);
                  cbi.setOptionDataSource(DataSource.get("COMPANY"));
                  cbi.setValueField("ID");
                  cbi.set[B]Foreign[/B]DisplayField("NAMETWICE");
                  cbi.setSortField("NAMETWICE");
                  companyIdLGF.setEditorProperties(cbi);
              }
      Best regards
      Blama

      Comment


        #4
        Hi Isomorphic,

        could you reproduce this one? It's a bad one IMHO.

        Best regards
        Blama

        Comment


          #5
          Apologies, this one slipped through - we'll take a look today.

          Comment


            #6
            Can you post the broken code again? We've tried based on your original code, and see no issues - but it's become a bit confused with various changes to various bits of the original sample, combined with cross-linking posts.

            Comment


              #7
              Hi Isomorphic,

              this is the whole code needed (retested with v11.1p_2018-01-29):

              BuiltInDS.java:
              Code:
              package com.smartgwt.sample.client;
              
              import com.google.gwt.core.client.EntryPoint;
              import com.smartgwt.client.Version;
              import com.smartgwt.client.core.KeyIdentifier;
              import com.smartgwt.client.data.DataSource;
              import com.smartgwt.client.util.Page;
              import com.smartgwt.client.util.PageKeyHandler;
              import com.smartgwt.client.util.SC;
              import com.smartgwt.client.widgets.IButton;
              import com.smartgwt.client.widgets.Window;
              import com.smartgwt.client.widgets.events.ClickEvent;
              import com.smartgwt.client.widgets.events.ClickHandler;
              import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
              import com.smartgwt.client.widgets.form.fields.SelectItem;
              import com.smartgwt.client.widgets.grid.ListGrid;
              import com.smartgwt.client.widgets.grid.ListGridField;
              import com.smartgwt.client.widgets.layout.VLayout;
              
              public class BuiltInDS implements EntryPoint {
                  public void onModuleLoad() {
                      KeyIdentifier debugKey = new KeyIdentifier();
                      debugKey.setCtrlKey(true);
                      debugKey.setKeyName("D");
              
                      Page.registerKey(debugKey, new PageKeyHandler() {
                          public void execute(String keyName) {
                              SC.showConsole();
                          }
                      });
              
                      VLayout mainLayout = new VLayout(20);
                      mainLayout.setWidth100();
                      mainLayout.setHeight100();
              
                      IButton recreateBtn = new IButton("Recreate SelectItem", new ClickHandler() {
                          @Override
                          public void onClick(ClickEvent event) {
                              recreate(true);
                          }
                      });
                      recreateBtn.setWidth(200);
              
                      IButton recreateBtn2 = new IButton("Recreate ComboBoxItem", new ClickHandler() {
                          @Override
                          public void onClick(ClickEvent event) {
                              recreate(false);
                          }
                      });
                      recreateBtn2.setWidth(200);
              
                      mainLayout.addMembers(recreateBtn, recreateBtn2);
              
                      recreate(false);
                      mainLayout.draw();
              
                  }
              
                  private void recreate(boolean asSelectItem) {
                      Window w = new Window();
                      w.setWidth("20%");
                      w.setHeight("20%");
                      w.setMembersMargin(0);
                      w.setModalMaskOpacity(70);
                      w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                      w.setTitle("SelectItem/ComboBoxItem problems with missing fetchRemoteDataReply" + w.getTitle());
                      w.setShowMinimizeButton(false);
                      w.setIsModal(true);
                      w.setShowModalMask(true);
                      w.centerInPage();
              
                      final ListGrid lg = new ListGrid();
                      lg.setDataSource(DataSource.get("RESELLER"));
                      lg.setCanEdit(true);
              
                      ListGridField companyIdLGF = new ListGridField("COMPANY_ID", asSelectItem ? "As SelectItem" : "As ComboBoxItem");
              
                      if (asSelectItem) {
                          SelectItem si = new SelectItem("ID");
                          si.setCachePickListResults(false);
                          si.setOptionDataSource(DataSource.get("COMPANY"));
                          si.setValueField("ID");
                          si.setForeignDisplayField("NAMETWICE");
                          si.setSortField("NAMETWICE");
                          companyIdLGF.setEditorProperties(si);
                      } else {
                          ComboBoxItem cbi = new ComboBoxItem("ID");
                          cbi.setCachePickListResults(false);
                          cbi.setOptionDataSource(DataSource.get("COMPANY"));
                          cbi.setValueField("ID");
                          cbi.setForeignDisplayField("NAMETWICE");
                          cbi.setSortField("NAMETWICE");
                          companyIdLGF.setEditorProperties(cbi);
                      }
              
                      ListGridField nameLGF = new ListGridField("NAME");
              
                      lg.setFields(companyIdLGF, nameLGF);
                      lg.fetchData();
                      w.addItem(lg);
                      w.show();
                  }
              }
              RESELLER.ds.xml (add in BuiltInDS.html):
              Code:
              <DataSource ID="RESELLER" serverType="sql" tableName="RESELLER">
                  <fields>
                      <field name="ID" type="integer" primaryKey="true" required="true" />
                      <field foreignKey="COMPANY.ID" displayField="COMPANY_NAME" name="COMPANY_ID" type="integer" />
                      <field name="COMPANY_NAME" includeFrom="COMPANY.NAME" />
                      <field name="NAME" type="text" />
                  </fields>
              </DataSource>
              COMPANY.ds.xml (add in BuiltInDS.html):
              Code:
              <DataSource ID="COMPANY" serverType="sql" tableName="COMPANY">
                  <fields>
                      <field name="ID" type="integer" primaryKey="true" required="true" />
                      <field name="NAME" type="text" />
                      <field name="NAMETWICE" customSelectExpression="COMPANY.NAME||COMPANY.NAME" />
                  </fields>
              </DataSource>
              Oracle DDL (also add ojdbc6.jar to project):
              Code:
              DROP TABLE reseller;
              DROP TABLE company;
              
              CREATE TABLE company (
                  id          INTEGER NOT NULL,
                  name        VARCHAR2(20),
                  CONSTRAINT company_pk PRIMARY KEY ( id ) ENABLE
              );
              
              CREATE TABLE reseller (
                  id           INTEGER NOT NULL,
                  company_id   INTEGER,
                  name         VARCHAR2(20),
                  CONSTRAINT reseller_pk PRIMARY KEY ( id ),
                  CONSTRAINT reseller_fk1 FOREIGN KEY ( company_id )
                      REFERENCES company ( id )
                  ENABLE
              );
              
              INSERT INTO company (ID,NAME)
              SELECT level, 'Company ' || to_char(level, '000') FROM dual connect by level<=400;
              
              INSERT INTO reseller (ID,company_id,NAME) VALUES (1,1,'Reseller 1');
              INSERT INTO reseller (ID,company_id,NAME) VALUES (2,100,'Reseller 2');
              INSERT INTO reseller (ID,company_id,NAME) VALUES (3,400,'Reseller 3');
              COMMIT;
              Please see this ComboBoxItem video:
              Click image for larger version

Name:	Missing fetchRemoteDataReply 1.gif
Views:	253
Size:	48.7 KB
ID:	251550
              I'd expect to see "Company 400Company 400" after the double click (-> as the ComboBoxItem only requests the first 75 rows for the pickList, this has to come from a (missing) fetchMissingValueReply-request).
              This happens the same for SelectItems:
              Click image for larger version

Name:	Missing fetchRemoteDataReply 3.gif
Views:	167
Size:	41.9 KB
ID:	251552


              Additional related(?) problem (ComboBoxItem only, just noticed) only with Company 001 (not with Company 400), if you show the pickList and do not select anything and hide it and then exit the editor (always reload the sample with F5 before, does only happen the 1st time):
              Click image for larger version

Name:	Missing fetchRemoteDataReply 2.gif
Views:	188
Size:	74.4 KB
ID:	251551

              Best regards
              Blama

              Comment


                #8
                Thanks, we'll take another look today.

                Comment


                  #9
                  A quick update on this issue - we have it reproduced and we'll update here when an appropriate fix is in

                  Comment


                    #10
                    Apologies for the delay in addressing this one - we've made a change that should fix the issue in both ComboBoxItem and SelectItem, for builds dated February 14 and later - please let us know if you see any issues with the fix.

                    Comment


                      #11
                      Hi Isomorphic,

                      using v11.1p_2018-02-14 and the testcase from #7 I still see the exact behavior from #7.
                      Did the change make it into the nightly? If so, does the testcase work for you?

                      Best regards
                      Blama

                      Comment


                        #12
                        The change was actually only made in 12.0 pending the results of an internal discussion as to its correctness - in the meantime, please try out the fix in 12.0 and let us know if you still see issues.

                        Comment


                          #13
                          Hi Isomorphic,

                          using the current 12.0d snapshot (SNAPSHOT_v12.0d_2018-02-14), I do see the fetchMissingValueReply-requests, so IMHO this looks good.

                          There is an issue though with the actions after exiting rowEditor. Here the display does not switch back to NAME from NAMETWICE and an unexpected UPDATE-request is triggered, even if you don't change anything.

                          Click image for larger version  Name:	Unexpected Update.gif Views:	1 Size:	46.2 KB ID:	251786

                          Click image for larger version  Name:	Unexpected Update_request.png Views:	1 Size:	4.6 KB ID:	251787

                          Best regards
                          Blama

                          Comment


                            #14
                            Thanks for the feedback - we'll incorporate this into the ongoing discussion and get back to you shortly.

                            Comment


                              #15
                              By way of a follow-up - after further investigation, you can ignore our previous comment about a fix having been applied to 12.0 - that was unnecessary and has been removed.

                              The proper way to deal with this situation is to call setUseLocalDisplayFieldValue(false) on your editor properties, and you can try that out in your current build.

                              We believe that, even with this technique, there's still a small issue with the foreign displayField not being replaced with the local one after initial editor enter *first ODS fetch), if the requested record isn't in the first page of results - we're looking into that, but let us know if you spot anything else.

                              Comment

                              Working...
                              X