Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    IPickTreeItem addChangeHandler doesn't work

    I want to capture the event when the iPickTreeItem's value changes on a selection. This code is never hit when I select the pick tree item.

    How do I access the onChange item for an iPickTreeItem?

    SmartClient Version: v9.1p_2014-07-22/PowerEdition Deployment (built 2014-07-22)
    Firefox 11

    TreeNode moreActionsRoot = new MoreActionsTreeNode("root",
    new MoreActionsTreeNode("Root", "Action1", "Action2"));

    Tree tree = new Tree();
    tree.setRoot(moreActionsRoot);

    IPickTreeItem moreActionsItem = new IPickTreeItem();
    moreActionsItem.setShowTitle(false);
    moreActionsItem.setValueTree(tree);
    moreActionsItem.addChangeHandler(new ChangeHandler() {

    @Override
    public void onChange(ChangeEvent event) {
    GWT.log("Change to " + event.getValue());

    }
    });

    public static class MoreActionsTreeNode extends TreeNode {

    public MoreActionsTreeNode(String name) {
    setName(name);
    }

    public MoreActionsTreeNode(String name, MoreActionsTreeNode... children) {
    setName(name);
    setChildren(children);
    }
    }

    #2
    We're not seeing a general issue with IPickTreeItem ChangeHandler, and there's nothing obviously wrong in the portion of your code you've shared.

    We'd recommend:

    1. Update to the latest patched build just in case (and since your build is quite out of date)

    2. If you're still having issues and you suspect a framework issue, create a minimal, standalone test case that we can run to see the problem

    Comment


      #3
      Updated to latest build, still seeing the issue

      I updated this the latest version for our paid SmartGWT 4.1p product.
      SmartClient Version: v9.1p_2015-04-15/PowerEdition Deployment (built 2015-04-15)

      I'm still seeing the issue. Any workaround? Please advice.

      Here's the source code.

      TreeNode moreActionsRoot = new MoreActionsTreeNode("root",
      new MoreActionsTreeNode("Root", "Action1", "Action2"));

      Tree tree = new Tree();
      tree.setRoot(moreActionsRoot);

      IPickTreeItem moreActionsItem = new IPickTreeItem();
      moreActionsItem.setShowTitle(false);
      moreActionsItem.setValueTree(tree);
      moreActionsItem.addChangeHandler(new ChangeHandler() {

      @Override
      public void onChange(ChangeEvent event) {
      GWT.log("Change to " + event.getValue());

      }
      });
      moreActionsItem.addChangedHandler(new ChangedHandler() {

      @Override
      public void onChanged(ChangedEvent event) {
      GWT.log("Changed to " + event.getValue());

      }
      });

      public static class MoreActionsTreeNode extends TreeNode {

      public MoreActionsTreeNode(String name) {
      setName(name);
      }

      public MoreActionsTreeNode(String name, MoreActionsTreeNode... children) {
      setName(name);
      setChildren(children);
      }
      }

      Comment


        #4
        We're in the same situation:

        We're not seeing a general issue with IPickTreeItem ChangeHandler, and there's nothing obviously wrong in the portion of your code you've shared.
        ...
        2. If you're still having issues and you suspect a framework issue, create a minimal, standalone test case that we can run to see the problem
        Your code isn't standalone - it just creates a FormItem, but doesn't cause it to appear on the screen.

        You need to not only create code that can actually be run to reproduce the problem, but test it in a fresh project (not your current application code, which could create the problem in a lot of different ways).

        Comment


          #5
          Standalone code proving that iPickTree onChange & onChanged doesn't work

          Here is some standalone code that you request. This will show that Click works but onChange & onChanged doesn't.

          Code:
          package com.nimblestorage.standalonepicktreeprovingissues;
          
          import com.google.gwt.core.shared.GWT;
          import com.smartgwt.client.widgets.form.DynamicForm;
          import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
          import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
          import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
          import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
          import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
          import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
          import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
          import com.smartgwt.client.widgets.layout.HLayout;
          import com.smartgwt.client.widgets.tree.Tree;
          import com.smartgwt.client.widgets.tree.TreeNode;
          
          public class StandaloneMoreActionsPickTreeLayout extends HLayout {
              private static final TreeNode moreActionsRoot = new MoreActionsTreeNode("root",
                      new MoreActionsTreeNode("subroot", new MoreActionsTreeNode("val1"),
                              new MoreActionsTreeNode("val2")));
          
              public StandaloneMoreActionsPickTreeLayout() {
                  final DynamicForm form = new DynamicForm();
                  form.setWidth(300);
          
                  Tree tree = new Tree();
                  tree.setRoot(moreActionsRoot);
          
                  IPickTreeItem moreActionsItem = new IPickTreeItem();
                  moreActionsItem.setShowTitle(false);
                  moreActionsItem.setValueField("moreActions");
                  moreActionsItem.setValueTree(tree);
                  moreActionsItem.setEmptyDisplayValue("More actions");
                  /*
                   * TODO: Opened a SmartGWT support request, since these change/changed handler doesn't
                   * work.
                   */
                  moreActionsItem.addChangeHandler(new ChangeHandler() {
          
                      @Override
                      public void onChange(ChangeEvent event) {
                          // Doesn't work
                          GWT.log("onChange works. Change to " + event.getValue());
                      }
                  });
                  moreActionsItem.addChangedHandler(new ChangedHandler() {
          
                      @Override
                      public void onChanged(ChangedEvent event) {
                          // Doesn't work
                          GWT.log("onChanged works. Changed to " + event.getValue());
                      }
                  });
                  moreActionsItem.addClickHandler(new ClickHandler() {
          
                      @Override
                      public void onClick(ClickEvent event) {
                          // This works
                          GWT.log("Click works.");
                      }
                  });
          
                  form.setItems(moreActionsItem);
                  setMembers(form);
              }
          
              public static class MoreActionsTreeNode extends TreeNode {
          
                  public MoreActionsTreeNode(String name) {
                      setName(name);
                  }
          
                  public MoreActionsTreeNode(String name, MoreActionsTreeNode... children) {
                      setName(name);
                      setChildren(children);
                  }
              }
          
          }

          Comment


            #6
            You've set valueField to "moreActions", yet none of your TreeNodes have such an attribute. Hence, selecting different nodes is not a change since all nodes have the value null for "moreActions".

            Not a bug, please revisit the samples to see how to properly use this component.

            Comment

            Working...
            X