Announcement

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

    ComboBoxItem "Loading..." only shows for initial "fetchMissingValues"

    Hi Isomorphic,

    It would appear that the "Loading..." display value displayed while fetchMissingValues is active and a fetch is pending, only displays the very first time a display value is fetched for the ComboBoxItem. If we edit a different record (via editRecord(Record)), when the value changes for the ComboBoxItem, the value flashes rather than the "Loading..." display value while the fetchMissingValues is active and a fetch is still pending.

    Do you know any way to ensure the "Loading..." is always displayed?

    Note, autoFetchData=false for the ComboBoxItem.

    Thanks

    SmartClient Version: v10.1p_2016-03-20/Pro Deployment (built 2016-03-20)

    #2
    Hi Isomorphic,

    It would appear that the behaviour changed here, as it did work as expected in previous releases. Please see below for summary of which releases it previously worked, and which releases it no longer works.

    Releases That Work
    SmartClient Version: v9.1p_2015-02-11/Pro Deployment (built 2015-02-11)
    SmartClient Version: v10.0p_2015-06-11/Pro Deployment (built 2015-06-11)

    Releases That Do Not Work
    SmartClient Version: SNAPSHOT_v10.1d_2015-10-25/Pro Deployment (built 2015-10-25)
    SmartClient Version: v10.1p_2016-03-20/Pro Deployment (built 2016-03-20)
    SmartClient Version: v10.1p_2016-04-05/Pro Deployment (built 2016-04-05)

    Regards

    Comment


      #3
      Thanks for the notification. We've made a change to address this issue. Please try the next nightly build (dated April 8 or above) to pick up the change.

      Regards
      Isomorphic Software

      Comment


        #4
        Thank you!
        Does this fix apply to the SelectItem as well?

        Comment


          #5
          I have verified in the nightly build and all is working great, including SelectItem.
          Thank you again.

          Comment


            #6
            Hi Isomorphic,

            We have discovered one outstanding issue in this area. If the value is multi-valued, it would appear the Loading... is not properly displaying.

            There are two scenarios here.

            1. All display values are missing: All values flash.
            2. Some display values cached, some missing: The display values that are cached appear immediately and the other values flash.

            Thanks

            Comment


              #7
              Hi,
              We're having trouble reproducing this.
              Could you show us some code to reproduce the problem? Just the client-side code to create and draw the DynamicForm/item[s] and populate it with values should be sufficient, and you could use one of the shipped dataSources such as "supplyItem" as the option dataSource.
              Also - please let us know which branch you're seeing this version of the problem on.

              Thanks
              Isomorphic Software

              Comment


                #8
                SmartClient Version: v10.1p_2016-04-28/Pro Deployment (built 2016-04-28)

                Just load the following sample, and click item1, no Loading..., just "1,2,3" while display values fetched, click item2, the display values already fetched for item1 appear, yet, the missing ones appear as values like "refItem2,refItem3,4", while missing display values fetched.

                Sandbox8.java
                Code:
                package com.sandbox.client;
                
                import java.util.ArrayList;
                import java.util.List;
                
                import com.google.gwt.core.client.EntryPoint;
                import com.smartgwt.client.core.KeyIdentifier;
                import com.smartgwt.client.data.DataSource;
                import com.smartgwt.client.data.fields.DataSourceIntegerField;
                import com.smartgwt.client.data.fields.DataSourceTextField;
                import com.smartgwt.client.types.AutoFitWidthApproach;
                import com.smartgwt.client.types.FetchMode;
                import com.smartgwt.client.types.RecordComponentPoolingMode;
                import com.smartgwt.client.util.Page;
                import com.smartgwt.client.util.PageKeyHandler;
                import com.smartgwt.client.util.SC;
                import com.smartgwt.client.widgets.form.DynamicForm;
                import com.smartgwt.client.widgets.form.fields.IntegerItem;
                import com.smartgwt.client.widgets.form.fields.SelectItem;
                import com.smartgwt.client.widgets.form.fields.TextItem;
                import com.smartgwt.client.widgets.grid.ListGrid;
                import com.smartgwt.client.widgets.grid.ListGridField;
                import com.smartgwt.client.widgets.grid.ListGridRecord;
                import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
                import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
                import com.smartgwt.client.widgets.layout.VLayout;
                
                public class Sandbox8 implements EntryPoint {
                
                    @Override
                    public void onModuleLoad() {
                        DataSource clientDs = new DataSource();
                        clientDs.setClientOnly(true);
                        clientDs.setID("sandbox8_client");
                        DataSourceIntegerField idField = new DataSourceIntegerField("id");
                        idField.setPrimaryKey(true);
                        DataSourceTextField nameField = new DataSourceTextField("name");
                        DataSourceTextField refNameField = new DataSourceTextField("refName");
                        refNameField.setMultiple(Boolean.TRUE);
                        DataSourceTextField refField = new DataSourceTextField("ref");
                        refField.setMultiple(Boolean.TRUE);
                        refField.setForeignKey("sandbox8.id");
                        refField.setDisplayField("refName");
                        clientDs.setFields(idField, nameField, refNameField, refField);
                
                        ListGridRecord record;
                        List<ListGridRecord> recordList = new ArrayList<ListGridRecord>();
                        for (long i = 1; i <= 15; i++) {
                            record = new ListGridRecord();
                            record.setAttribute("id", i);
                            record.setAttribute("name", "item" + i);
                            record.setAttribute("refName", new String[] { "refItem" + i, "refItem" + (i + 1), "refItem" + (i + 2) });
                            record.setAttribute("ref", new String[] { i + "", (i + 1) + "", (i + 2) + "" });
                            recordList.add(record);
                        }
                
                        clientDs.setCacheData(recordList.toArray(new ListGridRecord[recordList.size()]));
                
                        final ListGrid list = new ListGrid();
                        list.setWidth100();
                        list.setHeight100();
                        list.setDataSource(clientDs);
                        list.setDataFetchMode(FetchMode.PAGED);
                        list.setAutoFitFieldsFillViewport(Boolean.TRUE);
                        list.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                        list.setAutoFitFieldWidths(Boolean.TRUE);
                        list.setCanFreezeFields(Boolean.FALSE);
                        list.setCanGroupBy(Boolean.FALSE);
                        list.setRecordComponentPoolingMode(RecordComponentPoolingMode.RECYCLE);
                        list.setAlternateRecordStyles(Boolean.TRUE);
                        list.setAutoFetchData(Boolean.TRUE);
                        list.setShowRollOver(Boolean.FALSE);
                
                        list.setDefaultFields(new ListGridField("id"), new ListGridField("name"), new ListGridField("ref"));
                
                        final DynamicForm form = new DynamicForm();
                        list.addRecordClickHandler(new RecordClickHandler() {
                            @Override
                            public void onRecordClick(RecordClickEvent event) {
                                ListGridRecord[] selectedRecords = list.getSelectedRecords();
                                if (selectedRecords != null && selectedRecords.length == 1) {
                                    form.editNewRecord(selectedRecords[0]);
                                }
                            }
                        });
                        form.setDataSource(clientDs);
                        form.setNumCols(2);
                        form.setWidth100();
                        form.setHeight100();
                        IntegerItem idItem = new IntegerItem("id");
                        idItem.setWidth("*");
                        TextItem nameItem = new TextItem("name");
                        nameItem.setWidth("*");
                        SelectItem referenceItem = new SelectItem("ref");
                        referenceItem.setOptionDataSource(DataSource.get("sandbox8"));
                        referenceItem.setMultiple(Boolean.TRUE);
                        referenceItem.setAutoFetchData(Boolean.FALSE);
                        referenceItem.setCachePickListResults(Boolean.FALSE);
                        referenceItem.setWidth("*");
                        referenceItem.setValueField("id");
                        referenceItem.setForeignDisplayField("name");
                        referenceItem.setAutoFetchData(Boolean.FALSE);
                        referenceItem.setDefaultValues(new String[0]);
                
                        form.setFields(idItem, nameItem, referenceItem);
                
                        VLayout vLayout = new VLayout();
                        vLayout.setWidth100();
                        vLayout.setHeight100();
                        vLayout.addMember(list);
                        vLayout.addMember(form);
                        vLayout.show();
                    }
                }
                sandbox8.ds.xml
                Code:
                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                <DataSource xmlns:fmt="WEB-INF/" ID="sandbox8" serverType="generic">
                    <fields>
                        <field name="id" type="text" primaryKey="true" canEdit="false">
                            <title>UUID</title>
                        </field>
                        <field name="name" type="text" length="255" required="true">
                            <title>Name</title>
                        </field>
                    </fields>
                    <serverObject lookupStyle="new" className="com.sandbox.server.Sandbox8DS"/>
                </DataSource>
                Sandbox8DS
                Code:
                package com.sandbox.server;
                
                import java.util.ArrayList;
                import java.util.HashMap;
                import java.util.List;
                import java.util.Map;
                import java.util.Set;
                
                import com.isomorphic.criteria.AdvancedCriteria;
                import com.isomorphic.criteria.Criterion;
                import com.isomorphic.datasource.DSRequest;
                import com.isomorphic.datasource.DSResponse;
                
                public class Sandbox8DS {
                
                    public Sandbox8DS() {}
                
                    public DSResponse fetch(final DSRequest req) {
                        DSResponse resp = new DSResponse();
                        String[] idList = getCriteriaValueAsString(req, "id");
                        if (idList != null) {
                            try {
                                Thread.sleep(2000); // Simulate delay while fetching missing display values.
                            } catch (InterruptedException e) {}
                            resp.setStartRow(0);
                            resp.setEndRow(idList.length);
                            resp.setTotalRows(idList.length);
                            List<Map<String, Object>> rList = new ArrayList<>();
                            for (String id : idList) {
                                HashMap<String, Object> r = new HashMap<String, Object>();
                                r.put("id", id);
                                r.put("name", "refItem" + id);
                                rList.add(r);
                            }
                            resp.setData(rList);
                        } else {
                            resp.setStartRow(req.getStartRow());
                            resp.setEndRow(req.getEndRow());
                            resp.setTotalRows(1000);
                            resp.setData(getTestData(req.getStartRow(), req.getEndRow()));
                        }
                        return resp;
                    }
                
                    private List<Map<String, Object>> getTestData(long startRow, long endRow) {
                        List<Map<String, Object>> rList = new ArrayList<Map<String, Object>>();
                        HashMap<String, Object> r;
                        String id;
                        for (long i = startRow; i <= endRow; i++) {
                            r = new HashMap<String, Object>();
                            id = Long.toString(i);
                            r.put("id", id);
                            r.put("name", "refItem" + id);
                            rList.add(r);
                        }
                        return rList;
                    }
                
                    protected static String[] getCriteriaValueAsString(DSRequest req, String fieldName) {
                        AdvancedCriteria criteria = req.getAdvancedCriteria();
                        if (criteria == null) return null;
                        Set<Criterion> criterions = criteria.getFieldCriterions(fieldName);
                        if ((criterions == null) || criterions.isEmpty()) return null;
                        if (criterions.size() == 1) {
                            Criterion criterion = criterions.toArray(new Criterion[criterions.size()])[0];
                            Object criterionValue = criterion.getValue();
                            if (criterionValue == null) return null;
                            if (criterionValue instanceof String) return new String[] { (String) criterionValue };
                        } else {
                            List<String> idList = new ArrayList<String>();
                            for (Criterion criterion : criterions) {
                                Object criterionValue = criterion.getValue();
                                if (criterionValue == null) return null;
                                if (criterionValue instanceof String) {
                                    idList.add((String) criterionValue);
                                }
                            }
                            if (!idList.isEmpty()) return idList.toArray(new String[idList.size()]);
                        }
                        return null;
                    }
                }

                Comment


                  #9
                  Hi Isomorphic,
                  Do you have everything you need from me for now?
                  Regards

                  Comment


                    #10
                    We do. We're reproducing the problem with this test case (thank you) and see where the problem is but don't yet have a fix.
                    We'll let you know as soon as we have a resolution

                    Regards
                    Isomorphic Software

                    Comment


                      #11
                      Thank you for the update.

                      Comment


                        #12
                        We've now made a change to address this issue. Please try the next nightly build, dated May 11 or above.

                        Regards
                        Isomorphic Software

                        Comment


                          #13
                          Thank you; I will verify when the build is available.

                          Comment


                            #14
                            The fix looks good. Thank you.

                            Comment

                            Working...
                            X