Hello guys.
I'm using smartGWT 2.5 with Firefox 11.
I have a IPickTreeItem and for some treeNodeValues I want to prevent the user from clicking them. Keeping that in mind, I was looking into the addChangeHandler method of the IPickTreeItem. I noticed that doing event.cancel did not cancelled the user change. Can you confirm this is a bug ?
Please see the code below.
OBS : The javadoc documentation for addChangeHandler is quite confusing :
Called when a FormItem's value is about to change as the result of user interaction. This method fires after the user performed an action that would change the value of this field, but before the element itself is changed.
Returning false cancels the change
Maybe it's a bug, because it's work as expected using a Button. I suspect that the problem come from the event.cancel(). It seems the event is not being cancelled.
Regards.
I'm using smartGWT 2.5 with Firefox 11.
I have a IPickTreeItem and for some treeNodeValues I want to prevent the user from clicking them. Keeping that in mind, I was looking into the addChangeHandler method of the IPickTreeItem. I noticed that doing event.cancel did not cancelled the user change. Can you confirm this is a bug ?
Please see the code below.
OBS : The javadoc documentation for addChangeHandler is quite confusing :
Called when a FormItem's value is about to change as the result of user interaction. This method fires after the user performed an action that would change the value of this field, but before the element itself is changed.
Returning false cancels the change
Code:
TreeNode treenode = new TreeNode("root", new TreeNode("Operation A"), new TreeNode("Operation B")); final DynamicForm dynamicForm = new DynamicForm(); Tree tree = new Tree(); tree.setRoot(treenode); final IPickTreeItem pickTreeItem = new IPickTreeItem(); pickTreeItem.setValueTree(tree); pickTreeItem.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { event.cancel(); // Do not prevent the change to occur pickTreeItem.clearValue(); // Not work either pickTreeItem.setValue((String)null); // Same } }); dynamicForm.setItems(pickTreeItem); dynamicForm.draw();
Code:
TreeNode treenode = new TreeNode("root", new TreeNode("Operation A"), new TreeNode("Operation B")); final DynamicForm dynamicForm = new DynamicForm(); Tree tree = new Tree(); tree.setRoot(treenode); final PickTreeItem pickTreeItem = new PickTreeItem(); pickTreeItem.setValueTree(tree); pickTreeItem.setDefaultValue("sdkfjsdkfj"); Button bt = new Button("click"); [B]bt.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { pickTreeItem.setValue((Object) null); } }); [/B] bt.draw(); dynamicForm.setItems(pickTreeItem); dynamicForm.draw();
Comment