Announcement

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

    MultiComboBoxItem cached display values treated as unknown values.

    SmartClient Version: v11.0p_2016-04-26/Pro Deployment (built 2016-04-26)

    Chrome

    I have a problem with a MultiComboBoxItem where the cached values from the option datasource are treated as unknown values.
    When I draw a MultiComboBoxItem and the option datasource values are cached I cant select anything.
    If I setAddUnknownValues to true, I can select the options but they are shown as their value instead of their display value.

    I have included a test case below, please follow these steps to recreate:
    1. Click button to open window with MultiComboBoxItem
    2. Open the picklist so the option datasource fetches it's values.
    3. Close the window
    4. Click button to open the window again.
    5. Open the picklist and try to select an option.
    Code:
    private Layout getLayout() {
        HLayout mainLayout = new HLayout();
        
        Button b = new Button();
        b.addClickHandler(new ClickHandler() {
            
            @Override
            public void onClick(ClickEvent event) {
                showWindow();
            }
        });
        mainLayout.addMember(b);
        return mainLayout;
    }
    
    private void showWindow() {
        
        DataSource ds = DataSource.get("test");
        
        MultiComboBoxItem comboBoxItem = new MultiComboBoxItem("comboBoxItem");
        comboBoxItem.setOptionDataSource(ds);
        comboBoxItem.setValueField("id");
        comboBoxItem.setDisplayField("name");
        
        DynamicForm form = new DynamicForm();
        form.setFields(comboBoxItem);
        
        Window window = new Window();
        window.setWidth(400);
        window.setHeight(400);
        window.centerInPage();
        window.addItem(form);
        window.show();
    }
    datasource (test.ds.xml)
    Code:
    <DataSource 
        ID="test" 
        serverConstructor="TestServlet">
         <fields>
            <field name="id"        type="sequence"    primaryKey="true"    />
            <field name="name"                                            />
         </fields>
    </DataSource>
    Servlet (TestServlet.java)
    Code:
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import com.isomorphic.datasource.BasicDataSource;
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    
    public class TestServlet extends BasicDataSource {
        
        public DSResponse executeFetch(DSRequest req) throws Exception {  
            List records = fetchRecords(req.getCriteria());  
            return new DSResponse(records);  
        }  
        
        private List fetchRecords (Map criteria) {  
            
            System.out.println("Fetch called!");
            
            List<Map> list = new ArrayList<>();
    
            Map one = new HashMap<>();
            one.put("id", 1);
            one.put("name", "one");
            list.add(one);
    
            Map two = new HashMap<>();
            two.put("id", 2);
            two.put("name", "two");
            list.add(two);
    
            Map three = new HashMap<>();
            three.put("id", 3);
            three.put("name", "three");
            list.add(three);
            
            return list;  
        }
    }

    #2
    Your DataSource implementation is broken - it will return the same three records even if the criteria specify just a specific record should be returned. We know this is just a test case, but if your real DataSource does something like this, that would be your problem.

    If you think there's a framework bug here, try creating an analogous test that uses either a clientOnly DataSource or relies on one of the sample DataSources from the SDK.

    Comment


      #3
      The datasource never sends a fetch request for a specific record so how can that be the problem?

      Comment

      Working...
      X