How to Embed a RAP Application in a Web Page

How to Embed a RAP Application in a Web Page

A slightly overlooked aspect of RAP Applications is that they do *not* have to take the whole page in your browser. Instead they can also be embedded into an existing web page. The example below is embedded into this blog post and is fully usable. My pet-term for such an application is “RAPplet” – kinda like an applet but without the need for a JVM in the browser.

 

Note: if you do not see a rap application above this text, your xml-based feed reader has swallowed the example :-o. Visit the current post with your browser!

Embedding a RAP Application in a Web Page

A straightforward iframe element will do the trick, as shown in the snippet below:

[code lang=”xml”]

[/code]

Happy hacking,
Elias.

9 Comments
  • Chris Aniszczyk (zx)
    Posted at 3:45 am, November 20, 2007

    Cool!!!

  • AlBlue
    Posted at 1:53 pm, November 20, 2007

    Shows up as a Server Error 500 and a NullPointerException for me.

  • Chris Aniszczyk (zx)
    Posted at 3:16 pm, November 20, 2007

    Is the source of this example available anywhere?

  • GrimTim
    Posted at 3:41 pm, November 20, 2007

    I get:

    java.lang.NullPointerException
    org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter.closeElementIfStarted(HtmlResponseWriter.java:689)
    org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter.startElement(HtmlResponseWriter.java:489)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleServiceHandlerSync.sendMultipleClientsPerSessionPage(RWTLifeCycleServiceHandlerSync.java:163)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleServiceHandlerSync.serviceInternal(RWTLifeCycleServiceHandlerSync.java:75)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleServiceHandlerSync.access$0(RWTLifeCycleServiceHandlerSync.java:48)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleServiceHandlerSync$1.service(RWTLifeCycleServiceHandlerSync.java:43)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleBlockControl$ServiceHandlerProcessor.run(RWTLifeCycleBlockControl.java:68)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleThreadPool$PoolRunnable.run(RWTLifeCycleThreadPool.java:38)
    org.eclipse.rwt.internal.lifecycle.RWTLifeCycleThreadPool$PoolWorker.run(RWTLifeCycleThreadPool.java:66)

    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.

  • Elias Volanakis
    Posted at 6:34 pm, November 20, 2007

    @Chris: the source is not available yet. I will do a posting about .war deployment and include the source there. If you want it earlier I can send it by email. It’s tiny anyway (3 classes).

    @alblue, grimtim: hmm, try reload :). The weird thing about the full stacktrace is that none of my code is on it. I’ll have a look at this though. Did you do something specific that could help me reproduce it?

    Regards,
    Elias.

  • Willian Mitsuda
    Posted at 9:03 pm, November 20, 2007

    Cool, but a little slow. Does it take a roundtrip to the server every time a button is pressed?

  • Elias Volanakis
    Posted at 10:51 pm, November 20, 2007

    @alblue, grimtim: the NullPointerException in HtmlResponseWriter was a RAP-bug that has been fixed in the meantime. I’m deploying a new version that has been compiled against RAP HEAD instead of RAP 1.0.

    @willian: yes, currently each click causes a round trip.

    Regards,
    Elias.

    PS: The calculator will be offline for the next 10 minutes or so…

  • Anonymous
    Posted at 12:42 pm, April 7, 2008

    “PS: The calculator will be offline for the next 10 minutes or so…”

    Maybe you meant the next 10 months? 🙂

  • Elias Volanakis
    Posted at 6:43 pm, April 7, 2008

    Hi anonymous,

    the RAP calculator is currently offline.

    I need a new server for hosting it. I’ll post a comment once i’ve found a new home for it.

    Regards,
    Elias.