Announcement

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

    Problem with the new ‘Special Values’ feature with ComboBoxItem.

    Problem with the new ‘Special Values’ feature with ComboBoxItem.

    The problem happens when the form receives data to edit - when there are no specialValues the combo makes a special ‘fetchMissingValueReply’ RPC call to get its displayValue and works fine, when there are 'specialValues' it does not try.

    I have included an example of this - it is based on the code in the 'Special Values' showcase sample. It goes wrong when the button labeled "Button" is clicked. The SelectItem works and ComboBoxItem does not.

    The file is designed to just overwrite the BuiltInDS.java file in the BuiltInDS sample and work with no other changes:

    Code:
    package com.smartgwt.sample.client;
    
    import java.util.LinkedHashMap;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
    import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class BuiltInDS implements EntryPoint {
    
    	/**
    	 * This is the entry point method.
    	 */
    	@Override
    	public void onModuleLoad() {
    		final DynamicForm form = new DynamicForm();
    		form.setWidth(500);
    		form.setNumCols(4);
    
    		SelectItem selectItem = new SelectItem();
    		selectItem.setOptionDataSource(DataSource.get("supplyItem"));
    		selectItem.setDisplayField("itemName");
    		selectItem.setValueField("itemID");
    		selectItem.setPickListWidth(300);
    		selectItem.setName("filteredSelect");
    		selectItem.setTitle("Choose an item (Select)");
    
    		ListGrid pickListProperties = new ListGrid();
    		pickListProperties.setShowFilterEditor(true);
    		selectItem.setPickListProperties(pickListProperties);
    		ListGridField skuField = new ListGridField("SKU");
    		ListGridField itemNameField = new ListGridField("itemName");
    		selectItem.setPickListFields(skuField, itemNameField);
    
    		LinkedHashMap<String,String> hashMap = new LinkedHashMap<String,String>();
    		hashMap.put("**EmptyValue**", "None");
    		hashMap.put("-1", "Not Applicable");
    		selectItem.setSpecialValues(hashMap);
    		selectItem.setSeparateSpecialValues(true);
    
    		ComboBoxItem comboBoxItem = new ComboBoxItem();
    		comboBoxItem.setName("filteredCombo");
    		comboBoxItem.setTitle("Choose an item (ComboBox)");
    		comboBoxItem.setAddUnknownValues(false);
    		comboBoxItem.setOptionDataSource(DataSource.get("supplyItem"));
    		comboBoxItem.setDisplayField("itemName");
    		comboBoxItem.setValueField("itemID");
    		comboBoxItem.setPickListWidth(300);
    		comboBoxItem.setPickListFields(skuField, itemNameField);
    
    		// ** COMMENT OUT BELOW ** //
    		comboBoxItem.setSpecialValues(hashMap);
    		comboBoxItem.setSeparateSpecialValues(true);
    		// ** END OF COMMENT OUT SECTION ** //
    
    		ButtonItem buttonItem = new ButtonItem("Button");
    		buttonItem.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) { 
    				int value = 9;
    
    				Record rec = new Record();
    				rec.setAttribute("filteredSelect", value);
    				rec.setAttribute("filteredCombo", value);
    
    				form.editRecord(rec);
    			}
    		});
    
    		ButtonItem buttonItem2 = new ButtonItem("Console");
    		buttonItem2.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) { 
    				SC.showConsole();
    			}
    		});
    
    		form.setFields(selectItem, comboBoxItem, buttonItem, buttonItem2);
    
    		form.draw();
    	}
    
    }
    If you remove the section below it works works as expected:

    Code:
        	// ** COMMENT OUT BELOW ** //
    
        comboBoxItem.setSpecialValues(hashMap);
    
        comboBoxItem.setSeparateSpecialValues(true);
    
        // ** END OF COMMENT OUT SECTION ** //

    SmartClient Version: v10.0p_2014-09-21/Pro Deployment (built 2014-09-21)


    Thank-you very much in advance.

    #2
    Thanks for the clear test case. There was indeed a bug here - we've fixed it in 5.0 and 5.1
    Please try the next nightly build, dated September 27 or above

    Regards
    Isomorphic Software

    Comment


      #3
      Thank-you very much for sorting it so quickly, todays build works fine. :-)

      Comment

      Working...
      X