google-code-export / gxt-uibinder

Automatically exported from code.google.com/p/gxt-uibinder
1 stars 0 forks source link

Tree item select event not working with @GxtUiHandler #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to get @GxtUiHandler to work with either 'Select' or 
'SelectionChanged' event on TreePanel.

I have done this successfully with:
tree.getSelectionModel().addSelectionChangedListener(
     new SelectionChangedListener<ModelData>() {
   @Override public void 
        selectionChanged(SelectionChangedEvent<ModelData> se) {
            ModelData md = se.getSelectedItem();
             etc...
        });

But this (and various other combinations/permutations) does not work:
@GxtUiHandler(eventType=GxtEvent.SelectionChange, uiField={"tree"})
    public void handleSelection(TreePanelEvent<BaseTreeModel> tpe){
    BaseTreeModel btm = tpe.getItem();
    String name = btm.get(NAME_FIELD);
    fireSelectedHandlers(name);

    System.err.println("selected " + name);
    }

Also, this works on TreePanel for CheckChange events:
@GxtUiHandler(
              eventType = GxtEvent.CheckChange, 
              uiField = { "tree" })
public void handleCheck(TreePanelEvent<BaseTreeModel> be) {
    ModelData md = be.getItem();
    BaseTreeModel btm = be.getItem();
    String name = md.get(NAME_FIELD);
    boolean checked = be.isChecked();
    String checkedTxt = (checked?"checked":"unchecked"); 
    System.err.println( name +" was " + checkedTxt);
    if(btm.getChildCount()>0){
        System.err.println(" has children ");
    }
}

any thoughts on why this is not working (I am not getting to the breakpoint at 
first line in handler method.

Original issue reported on code.google.com by joel.re...@gmail.com on 18 Mar 2011 at 7:07

GoogleCodeExporter commented 9 years ago
It looks like the problem is the fact that this isn't binding the listener 
directly on the TreePanel (the widget configured in the UiBinder XML with 
ui:field), which is what is supported with @GxtUiHandler.  This, however, 
requires adding the SelectionChangedEvent handler on the SelectionModel.

I'll have to consider how this could be done easily. 

Original comment by jus...@jhickman.com on 19 Mar 2011 at 3:54

GoogleCodeExporter commented 9 years ago
Changing type to Enhancement as using @GxtUiHandler on a widgets SelectionModel 
is not currently supported.  Only adding event handlers directly to widgets in 
the UiBinder is supported.

Original comment by jus...@jhickman.com on 23 Mar 2011 at 2:18