Is there a way to reuse this UI widget without generating new
javascript for each MenuBar? GWT will not be the container for the
Page.
If the above approach will work then I will need a method to pass
either a integer or string in the Client Entry point which will
represent which menu needs to be built. Any ideas how this would be
done?
Thanks!
Scott.
You have to use JSNI - Java Script Native Interface...
You can define a "bridge" method via JSNI that provides an external,
globally visible JavaScript function that can be called by your hand-
crafted JavaScript code. For example,
package mypackage;
public MyUtilityClass
{
public static int computeLoanInterest(int amt, float interestRate,
int term) { ... }
public static native void defineBridgeMethod() /*-{
$wnd.computeLoanInterest = function(amt, intRate, term) {
return @mypackage.MyUtilityClass::computeLoanInterest(IFI)
(amt, intRate, term);
}
}-*/;
}
On application initialization, call
MyUtilityClass.defineBridgeMethod() (e.g. from your GWT Entry Point).
This will create a function on the window object called
"computeLoanInterest" which will invoke, via JSNI, the compiled Java
method of the same name. The bridge method is needed because the GWT
compiler will obfuscate/compress/rename the names of Java methods when
it translates them to JavaScript.
Thanks
On Feb 5, 6:37 pm, "sdever98" <sde...@silverpop.com> wrote:
> I have built a UIWidgetwhich is very similar to the MenuBar. I want
> to use thisgenericUIwidgetthroughout my application and in some
> cases I might have more then 1 MenuBar per JSP page. My goal is to
> build one dynamic driven MenuBar that I can reuse without generating a
> seperate Javascript file for each instance. The menubar I have
> written loads the menubar properties, styles and items from the server
> so I think I am half way there.
>
> Is there a way to reuse this UIwidgetwithout generating new