Using:
SmartGWT v8.3d_2012-10-22/LGPL Development Only (built 2012-10-22)
FF 6.0.2
I initialize a SelectItem with a LinkedHashMap<String, String>:
When I call selectItem.setValue (2) (type = int and not String), this is what I get when I call getValue ():
When I call selectItem.setValue ("2") (type = String, matching the valueMap), this is what I get when I call getValue ():
Test case:
It seems that for getValue () to work, with SmartGWT 3.0p-2012-04-26 I could call either selectItem.setValue (2) or selectItem.setValue ("2"), but with 3.1d-2012-10-22 I need to call selectItem.setValue ("2").
In other words, the type needs to match.
Is this by design?
SmartGWT v8.3d_2012-10-22/LGPL Development Only (built 2012-10-22)
FF 6.0.2
I initialize a SelectItem with a LinkedHashMap<String, String>:
Code:
valueMap.put ("1", "Value 1"); valueMap.put ("2", "Value 2");
Code:
00:03:02.107 [INFO] selectItem.getValue (): null 00:03:02.107 [INFO] selectItem.getValueAsString (): 2
Code:
00:04:11.975 [INFO] selectItem.getValue (): 2 00:04:11.975 [INFO] selectItem.getValueAsString (): 2
Code:
import java.util.LinkedHashMap; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.SubmitItem; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; import com.smartgwt.client.widgets.layout.HLayout; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; public class SelectItemGetValue implements EntryPoint { /** * The EntryPoint interface */ public void onModuleLoad () { // add a SelectItem with data sorted in order c/b/a // this SelectItem properly respects the LinkedHashMap order c, b, a final LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String> (); valueMap.put ("1", "Value 1"); valueMap.put ("2", "Value 2"); final SelectItem selectItem = new SelectItem (); selectItem.setTitle ("selectItem"); selectItem.setValueMap (valueMap); // when calling selectItem.setValue (2); // 00:03:02.107 [INFO] selectItem.getValue (): null // 00:03:02.107 [INFO] selectItem.getValueAsString (): 2 // when calling selectItem.setValue ("2"); // selectItem.setValue ("2"); // 00:04:11.975 [INFO] selectItem.getValue (): 2 // 00:04:11.975 [INFO] selectItem.getValueAsString (): 2 // form final SubmitItem submitItem = new SubmitItem (); final DynamicForm form = new DynamicForm (); form.setWrapItemTitles (false); form.setFields (selectItem, submitItem); form.addSubmitValuesHandler (new SubmitValuesHandler () { public void onSubmitValues (final SubmitValuesEvent event) { GWT.log ("selectItem.getValue (): " + selectItem.getValue ()); GWT.log ("selectItem.getValueAsString (): " + selectItem.getValueAsString ()); } }); // display final HLayout mainLayout = new HLayout (); mainLayout.setWidth100 (); mainLayout.setHeight100 (); mainLayout.addMember (form); mainLayout.draw (); } }
In other words, the type needs to match.
Is this by design?
Comment