here's the example which I created from a test case:
As you can see from the code if I set the value of the select using "Set 26 on Select" button
the
is called and the output is printed out:
SET str:26
If I use
- no
(as well no
triggered) - the item just change it's value.
Please advise me what function should I overrride for the PickTreeItem in order to handle setting the value from the valuesManager.setValue or valuesManager.setValues.
For this issue I use: SmartClient Version: v10.0p_2015-08-28/PowerEdition Deployment (built 2015-08-28)
Code:
package com.smartgwt.sample.showcase.client.dataintegration.java.form; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.PickTreeItem; import com.smartgwt.client.widgets.layout.HStack; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tree.Tree; import com.smartgwt.client.widgets.tree.TreeNode; import com.smartgwt.sample.showcase.client.PanelFactory; import com.smartgwt.sample.showcase.client.ShowcasePanel; public class FormValidationSample extends ShowcasePanel { private static final String DESCRIPTION = "<p>ValuesManager does NOT trigger setValue</p>"; public static class Factory implements PanelFactory { private String id; public Canvas create() { FormValidationSample panel = new FormValidationSample(); id = panel.getID(); return panel; } public String getID() { return id; } public String getDescription() { return DESCRIPTION; } } public Canvas getViewPanel() { final DynamicForm form = new DynamicForm(); final ValuesManager valuesManager= new ValuesManager(); form.setValuesManager(valuesManager); valuesManager.addMember(form); //create tree - no values 25 or 26 Tree tree = new Tree(); TreeNode rootNode = new TreeNode("root"); tree.setRoot(rootNode); TreeNode newNode = new TreeNode("Parent1"); tree.add(newNode, rootNode); TreeNode childNode = new TreeNode("Child 1"); tree.add(childNode, newNode); final PickTreeItem select = new PickTreeItem("name", "text") { @Override public void setValue(String str){ System.out.println("SET str:" + str); super.setValue(str); } @Override public void setValue(Object str){ System.out.println("SET obj:" + str); super.setValue(str); } }; select.setValueTree(tree); form.setItems(select); //set 26 using select IButton clearErrorsButton = new IButton("Set 26 on Select"); clearErrorsButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // form.clearErrors(true); select.setValue("26"); } }); //set 25 using ValuesManager IButton clearErrorsButton25 = new IButton("Set 25 on ValuesManager"); clearErrorsButton25.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { valuesManager.setValue("name", "25"); } }); HStack buttons = new HStack(10); buttons.setHeight(24); buttons.setMembers( clearErrorsButton, clearErrorsButton25); VLayout layout = new VLayout(10); layout.setMembers(form, buttons); return layout; } public String getIntro() { return DESCRIPTION; } }
Code:
select.setValue("26");
Code:
setValue(Object str)
SET str:26
If I use
Code:
valuesManager.setValue("name", "25");
Code:
setValue(Object str)
Code:
handleChangeEvent( ChangeEvent event )
Please advise me what function should I overrride for the PickTreeItem in order to handle setting the value from the valuesManager.setValue or valuesManager.setValues.
For this issue I use: SmartClient Version: v10.0p_2015-08-28/PowerEdition Deployment (built 2015-08-28)
Comment