Hi,
I'm trying to do what's described in this post, that is setting the Form's value on a custom FormItem so I can call this value via Form.getValues().
However, the reference to getForm() inside the FormItem is null.
Repro case:
SmartGWT 1.3
I'm trying to do what's described in this post, that is setting the Form's value on a custom FormItem so I can call this value via Form.getValues().
However, the reference to getForm() inside the FormItem is null.
Repro case:
SmartGWT 1.3
Code:
private class MyCanvasItem extends CanvasItem { private int timesClicked = 0; public MyCanvasItem() { super(); Button b = new Button("Click me"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { timesClicked++; DynamicForm form = MyCanvasItem.this.getForm(); if (form == null) { SC.say("Form reference is null :("); } else { form.setValue(MyCanvasItem.this.getName(), timesClicked); } } }); setCanvas(b); } } private Canvas getFormRefTest() { VLayout result = new VLayout(); final DynamicForm form = new DynamicForm(); TextItem field1 = new TextItem("field1"); MyCanvasItem field2 = new MyCanvasItem(); field2.setName("field2"); field2.setTitle("Field 2"); form.setFields(field1, field2); Button getValueMap = new Button("Show values"); getValueMap.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Map<String, String> map = form.getValues(); StringBuffer string = new StringBuffer("Form Value Map:<br/>"); for (String key : map.keySet()) { string.append(key).append(": ").append(map.get(key)).append("<br/>"); } SC.say(string.toString()); } }); result.setMembers(form, getValueMap); return result; }
Comment