GWT Flex Bridge

A recent thread on the GWT forum got me interested in the possibility of interfacing GWT to Adobe Flex. Adobe have released a javascript to flex ‘bridge’ component called FABridge.

I have put together a (very) quick and dirty demo the two components talking to each other through the FABridge. This is far from finished but is does demonstrate the basic concepts.

Download the zip file from here.

If you examine the source code you will see that I have tried to enclose the embedding of the swf component within the ‘FlexWidget’ by writing the holder html straight into the main html view. The controller object is then supposed to pick up the embedded object in the JNSI code. This doesn’t work. I am looking into why not.

GWT Flex demo here. Only works in Firefox/Mozilla/Opera browsers for the moment.

Source code here.

Comments

4 Responses to “GWT Flex Bridge”

  1. Jana on October 16th, 2007 4:48 pm

    Hi,

    I’ve read thru this thread and hoping I didn’t miss something, but I too am trying to use FABridge to have the GWT talk to a flex application. I’m using the flex.zip example to create the FlexWidget and FlexController objects, etc. Everything will work if I put the flex tags (or ) directly in the HTML. The problem I’m running into is if I want to create the flex component from inside GWT and add it, then I get the following error when using Firefox.

    Error: $wnd.FABridge[a] has no properties
    Source File: file:///C:/Documents%20and%20Settings/puffenbergej/My%20Documents/eclipse3-3/tap-gwt/www/com.saic.tapo.App/090E63B8BF7557FD3B82A20CBA4549F4.cache.html
    Line: 639

    If I run it in the debugger I get the following stack trace. The lines of code it throws this in is as follows:

    public static native FlexController create(String name) /*-{
    return $wnd.FABridge[name].root();
    }-*/;

    [ERROR] Uncaught exception escaped
    com.google.gwt.dev.shell.HostedModeException: invokeNativeHandle(@com.saic.tapo.client.FlexControllerImpl::create(Ljava/lang/String;)): JavaScript undefined, expected com.saic.tapo.client.FlexController
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:101)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeHandle(ModuleSpace.java:226)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeHandle(JavaScriptHost.java:89)
    at com.saic.tapo.client.FlexControllerImpl.create(FlexControllerImpl.java:5)
    at com.saic.tapo.client.FlexController.create(FlexController.java:13)
    at com.saic.tapo.client.FlexWidget$2.run(FlexWidget.java:85)
    at com.google.gwt.user.client.Timer.fireImpl(Timer.java:164)
    at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:150)
    at com.google.gwt.user.client.Timer.fire(Timer.java:142)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
    Below are code snippets:

    // the above errors show up around 5 seconds which is when the timer to create the FlexController happens as shown below:

    /**
    * Creates timeline, elements have to be setup prior to calling this.
    *
    */
    public void create()
    {
    if (visible())
    {
    Timer t = new Timer() {
    public void run()
    {
    // Create wrapper around flex component
    controller = FlexController.create(flexName);

    }
    };

    t.schedule(5000);

    }
    }

    // Below is the code I use to create the widget. Then 5 seconds later it throws an exception.
    // first I add the flex code to the html dynamically

    FlexWidget flexControl = new FlexWidget(“100%”, “100%”, “b_tapo”,”flex/tap.swf”);
    flexControl.setSize(“1400px”, “800px”);

    RootPanel.get().add(flexControl);

    Jana

  2. Pablo on June 25th, 2009 9:26 pm

    Hi .
    I need to pass some properties from my GWT application to my flex , do you know how can I do this?

  3. Administrator on July 11th, 2009 5:06 pm

    Pablo, You will need to use something like FABridge which forms a Flex/Ajax bridge between the javascript and the Flex application. I haven’t been keeping up with GWT and flex recently but I do know that this component only works under Firefox and IE7 with any degree of consistency. I have a horrible feeling it’s broken under IE8.

  4. Alain Ekambi on May 30th, 2011 6:29 pm

    Please have a look at http://code.google.com/p/gwt4air/
    I just released a GWT API for Flex
    Regards,

    Alain

Leave a Reply