Domanda

I have an object that implements "IsTreeItem". The Object is displayed as a two level tree item. Each tree item is built with a check box. I need to know when a check box is changing value - so i am listening to ValueChangedEvents.

The first problem is that the Tree built with such items only fires SelectionEvents. If selection is changing the check box the ValueChanged event is fired afterwards - so there is no way to listen to events inside "IsTreeItem" from Tree.

So i let my "IsTreeItem" fire its own element. So i (field)injected an EventBus and used it to fire the event if "ValueChanged". The Problem is that my "IsTreeItem" is an Object sent from server (it is in shared package and serializable). The object is instantiated on server (EventBus is not ionjected) and "asTreeItem" is called on client.

Is there a way to inject the EventBus in the Method TreeItem asTreeItem() in some way? Or are there any other means to let some one outside know if a check box has changed its value.

È stato utile?

Soluzione

GIN can do member injection on already created instances.

You have to create a method in your Ginjector interface that takes such an instance as argument, with a return type of void.
Note that because no reflection is done on the client, GIN will only inject fields and methods from the class used as the argument type (and its super-classes).

@GinModules(MyGinModule.class)
interface MyGinjector extends Ginjector {
    …

    void injectIsTreeItemMembers(IsTreeItem item);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top