I am calling it on the CheckboxItem directly. I am doing this because i have them stored in an array. Its just a really basic check box list.
private CheckboxItem[] widgetChoices = new CheckboxItem[3];
widgetChoices[0] = new CheckboxItem("1");
widgetChoices[1] = new CheckboxItem("2");
widgetChoices[2] = new CheckboxItem("3");
private DynamicForm form = new DynamicForm();
form.setFields(widgetChoices);
public LinkedList<String> getCheckedItem(){
LinkedList<String> toReturn = new LinkedList<String>();
for(int i = 0; i < widgetChoices.length; i++){
if((Boolean)widgetChoices[i].getValue() == true){
toReturn.add(widgetChoices[i].getName());
}
}
return toReturn;
}
I wrote a simpler test that shows the error better:
public class MainEntryPoint implements EntryPoint {
public void onModuleLoad() {
DynamicForm form = new DynamicForm();
form.setNumCols(1);
CheckboxItem[] list = new CheckboxItem[3];
for(int i = 0; i < list.length; i++){
list[i] = new CheckboxItem(Integer.toString(i));
list[i].setValue(false);
System.out.println(list[i].getValue());
list[i].setRedrawOnChange(true);
}
form.setFields(list);
}
This code won’t even compile, as GWT is complaining about the CheckboxItem.getValue() method
[ERROR] Unable to load module entry point class test.client.MainEntryPoint (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): self.getValue is not a function
fileName: jar:file:/home/paperclip/workspace/HDDSS-smartGWT/lib/smartgwt.jar!/com/smartgwt/client/widgets/form/fields/FormItem.java
lineNumber: 2253
stack: ()@jar:file:/home/paperclip/workspace/HDDSS-smartGWT/lib/smartgwt.jar!/com/smartgwt/client/widgets/form/fields/FormItem.java:2253
gwtOnLoad([object Window],"test.MainEntryPoint","1.5")@:0
gwtOnLoad((function () {alert("Failed to load module test.MainEntryPoint\".\nPlease see the log in the development shell for details.");}),"test.MainEntryPoint","http://localhost:8888/test.MainEntryPoint/")@http://localhost:8888/test.MainEntryPoint/hosted.html?test_MainEntryPoint:20
maybeStartModule()@http://localhost:8888/test.MainEntryPoint/test.MainEntryPoint.nocache.js:100
()@http://localhost:8888/test.MainEntryPoint/test.MainEntryPoint.nocache.js:354
@http://localhost:8888/test.MainEntryPoint/hosted.html?test_MainEntryPoint:39
at com.smartgwt.client.widgets.form.fields.FormItem.getValue(Native Method)
at test.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:20
Thanks for the testcase. I’ll look into this. The issue here is related to calling of getValue() before the form has been rendered. Can you try running that code in, say, a Button click listener so that it executes after the form has been rendered.
It seems like if I set the value initially via CheckboxItem.setValue(false) then the error goes away. Accessing the value via CheckboxItem.getValue.equals(true) then becomes possible!