Monday, November 19, 2007

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 calculator 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.





Embedding a RAP Application in a Web Page

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

<iframe
src="http://rap.eclipse.org/maildemo/rap?startup=maildemo"
width="400" height="400" frameborder="0"
name="maildemo">
<p>Sorry your browser does not support iframes.</p>
</iframe>

Happy hacking,
Elias.

9 comments:

Chris Aniszczyk (zx) said...

Cool!!!

AlBlue said...

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

Chris Aniszczyk (zx) said...

Is the source of this example available anywhere?

GrimTim said...

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 said...

@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 said...

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

Elias Volanakis said...

@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 said...

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

Maybe you meant the next 10 months? :)

Elias Volanakis said...

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.