Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Sharing objects between GWT modules in different Equinox bundles

Hi,

You can find answers with gwt-api-interop project from
http://code.google.com/p/gwt-api-interop/ . With api-interop you can
define classes in gwt that will be accessible from javascript (without
obfuscation) . So you can define *interfaces* that can be used between
gwt projects. I don't know the limitation, I did a basic
implementation to merge panels and it worked well.

Hope it can help,
Olivier




2008/9/23 Ricardo Giacomin <ricardo.giacomin@xxxxxxxxxxxxx>:
> 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) {
>
>
> handler.@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.event.BaseItemListenerAdapter::onClick(Lcom/gwtext/client/widgets/menu/BaseItem;Lcom/gwtext/client/core/EventObject;)(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
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>


Back to the top