I am trying to make a ToolStrip fire an event when its content has changed,
what I do not understand is how to register the handler, I must be doing something wrong since the handler count is 0 both before and after the call to addDataChangedHandler.
Also I have not been able to figure out how to actually fire the
event in _test(); I tried something like
but I do not know what to give as argument.
Anyone know what is wrong with this picture ?
what I do not understand is how to register the handler, I must be doing something wrong since the handler count is 0 both before and after the call to addDataChangedHandler.
Also I have not been able to figure out how to actually fire the
event in _test(); I tried something like
Code:
fireEvent(new DataChangedEvent(jsObj));
Anyone know what is wrong with this picture ?
Code:
import com.google.gwt.event.shared.HandlerRegistration; import com.smartgwt.client.data.events.DataChangedEvent; import com.smartgwt.client.data.events.DataChangedHandler; import com.smartgwt.client.data.events.HasDataChangedHandlers; import com.smartgwt.client.widgets.toolbar.ToolStrip; public class DataSourceToolbar extends ToolStrip implements HasDataChangedHandlers { public void _test(){ Util.logMessage("FIRING EVENT"); } @Override public HandlerRegistration addDataChangedHandler(DataChangedHandler handler) { Util.logMessage("Registering handler"); return addHandler(handler, DataChangedEvent.getType()); } }
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.events.DataChangedEvent; import com.smartgwt.client.data.events.DataChangedHandler; public class Test implements EntryPoint { /** * The DataSourceObject contains information which describes what * information to load, and with it we can recreate the request url. */ DataSourceObject ds; /* (non-Javadoc) * @see com.google.gwt.core.client.EntryPoint#onModuleLoad() */ public void onModuleLoad() { DataSourceToolbar t = new DataSourceToolbar(); Util.logMessage(String.valueOf(t.getHandlerCount(DataChangedEvent.getType()))); t.addDataChangedHandler(new DataChangedHandler() { @Override public void onDataChanged(DataChangedEvent event) { Util.logMessage("EVENT RECEIVED"); } }); Util.logMessage(String.valueOf(t.getHandlerCount(DataChangedEvent.getType()))); t._test(); t._test(); t._test(); } }
Comment