Att.: To anyone experienced with Equinox + GWT (apologies to others, I
considered more likely to find someone here who could help me than in the
GWT list)

 

----

Hi,

 

I have two bundles each encapsulating a GWT module (say B1 and B2). My goal
is that the second bundle (B2) could contribute with menu items to the main
one (B1). In B2 onModuleLoad() entry point, I would append to the JavaScript
'window' object the menu item listener (see listing 1 below) and in the B1
menu event handler I would get this object and call onClick() method (see
listing 2).

 

Listing 1

======

public class Fragment implements EntryPoint {

 

                public void onModuleLoad() {

                               final String key = "callback" +
this.getClass().getName() + ".command1";

                               BaseItemListenerAdapter obj = new
BaseItemListenerAdapter() {

                                               @Override

                                               public void onClick(BaseItem
item, EventObject e) {

 
Window.alert("item: " + item + "; event: " + e);

 
super.onClick(item, e);

                                               }

                               };

                               setHandler(key, obj);

                }

 

                public static native void setHandler(String key,
BaseItemListenerAdapter handler)/*-{

                                window[key] = function(item, event) {

 
[EMAIL PROTECTED]::onCli
ck(Lcom/gwtext/client/widgets/menu/BaseItem;Lcom/gwtext/client/core/EventObj
ect;)(item,event);

                                }

                }-*/;

}

 

Listing 2

======

.

                protected void onMenuItemSelected(BaseItem item, EventObject
event) {

                               final String key = "callback" +
Fragment.class.getName() + ".command1";

                               callHandler(key, item, event);

                }

 

                public static native void callHandler(String key, BaseItem
item, EventObject event)/*-{

                    window[key](item, event);

                }-*/;

 

 

The problem is that in the second bundle window[key] returns "unresolved".
If setHandler() and callHandler() are both in the same bundle, everything
works perfectly.

 

Is the approach viable? Is there any other alternative? 

 

Any help would be appreciated.

                

Regards,

Ricardo Giacomin

_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to