<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EclipseSource Blog &#187; rap</title>
	<atom:link href="http://eclipsesource.com/blogs/tag/rap/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsesource.com/blogs</link>
	<description>Eclipse Equinox OSGi</description>
	<lastBuildDate>Thu, 23 May 2013 16:16:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to Bootstrap a Tabris Application with Maven and Eclipse</title>
		<link>http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/</link>
		<comments>http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/#comments</comments>
		<pubDate>Tue, 14 May 2013 13:22:05 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[Tabris]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=15753</guid>
		<description><![CDATA[From my point of view bootstrapping a new application is always tricky. Especially when you want to bootstrap an app that uses technology you are not yet familiar with. With this post I want to give you a step by step tutorial on how to bootstrap a Tabris application using Eclipse and Maven. So, let&#8217;s <a href="http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>From my point of view bootstrapping a new application is always tricky. Especially when you want to bootstrap an app that uses technology you are not yet familiar with. With this post I want to give you a step by step tutorial on how to bootstrap a <a href="http://developer.eclipsesource.com/tabris/">Tabris application</a> using Eclipse and Maven. So, let&#8217;s get our hands dirty!</p>
<p><strong>IDE Setup</strong></p>
<p>The first thing you need to do is to download the latest &#8220;<a href="http://www.eclipse.org/downloads/">Eclipse IDE for Java EE Developers</a>&#8220;. This package contains everything you need to create web applications and deploy them to the application servers of your choice. As we want to bootstrap the application with Maven, we also need to install additional tools called &#8220;<a href="http://www.eclipse.org/m2e/">m2e</a>&#8221; which provide a Maven integration for Eclipse. So, after starting your new IDE, go to</p>
<p>&#8220;Help&#8221; -&gt; &#8220;Install New Software&#8221; and paste the p2 repository url (<em>http://download.eclipse.org/technology/m2e/releases</em>) of m2e into the text box. This should look like the screenshot below.</p>
<p><img class="aligncenter" alt="m2e installation How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/m2e-installation.png" width="686" height="650" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p>After the installation was successful, you need to restart the IDE.</p>
<p><strong>Create a Project</strong></p>
<p>The next step is to create a new project. Tabris applications run on the server side. So, we want to create a Web-application project. For this go to <em>&#8220;File&#8221; -&gt; &#8220;New&#8221; -&gt; &#8220;Dynamic Web Project&#8221;, </em>which basically creates a JavaEE project.</p>
<p><img class="aligncenter" alt="new project How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/new-project.png" width="539" height="532" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p>In my example I have named the project &#8220;com.eclipsesource.hello.world&#8221; but you can choose whatever name you like.</p>
<p><strong>Maven</strong></p>
<p>To make things as easy as possible we want <a href="http://maven.apache.org/">Maven</a> to manage our dependencies. This involves two steps. Firstly, we want to have the dependencies during development time and secondly, we want Eclipse to put those dependencies in our &#8220;lib&#8221; folder during deployment time. The first step can be completed easily. Just right click on the newly created project and press <em>&#8220;Configure&#8221; -&gt; &#8220;Convert to Maven Project&#8221;</em>.</p>
<p><img class="aligncenter" alt="convert project How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/convert-project.png" width="580" height="593" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p>This adds a pom.xml to our project to which we can later add dependencies. The second step is a little bit more complicated. To have the depencies copied into the &#8220;lib&#8221; folder we need to create a &#8220;Deployment Assembly&#8221;. To create this, right click on the project and select <em>&#8220;Properties&#8221;</em>. In the left hand navigation tree, select &#8220;Deployment Assembly&#8221;. Within this page we need to add a new assembly. So, click on <em>Add</em> and choose <em>&#8220;Java Build Path Entries&#8221;</em>.</p>
<p style="text-align: center;"><img class="aligncenter" alt="new assembly How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/new-assembly.png" width="526" height="415" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;">After pressing &#8220;Next&#8221; we need to tell Eclipse which build path entry we want to have copied. As we want the Maven dependencies to be copied,  we will choose these.</p>
<p style="text-align: left;"><img class="aligncenter" alt="maven assembly How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/maven-assembly.png" width="528" height="416" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;">On your machine the dependency tree may be empty, but this is not a problem. Just select &#8220;Maven Dependencies&#8221; and press &#8220;Finish&#8221;. After this you should see the newly created assembly pointing to the &#8220;lib&#8221; folder.</p>
<p style="text-align: left;"><img class="aligncenter" alt="assembly result How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/assembly-result.png" width="618" height="536" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;"><strong>Add Tabris</strong></p>
<p style="text-align: left;">After having completed the Maven setup, we can add  a dependency to Tabris because we want to build a Tabris app, right <img src='http://eclipsesource.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt="icon smile How to Bootstrap a Tabris Application with Maven and Eclipse" class='wp-smiley' title="How to Bootstrap a Tabris Application with Maven and Eclipse" /> ? So, open the &#8220;pom.xml&#8221; of your project and go to the dependency section. Select &#8220;Add&#8221; and search for &#8220;tabris&#8221;. At this point in time <a href="http://developer.eclipsesource.com/tabris/roadmap/">Tabris 1.0</a> is the current version. Before you select it please make sure that the dependency scope is set to &#8220;runtime&#8221;.</p>
<p style="text-align: left;"><img class="aligncenter" alt="tabris dependency How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/tabris-dependency.png" width="482" height="452" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;">After pressing OK and saving the pom.xml Eclipse (m2e) will download Tabris and it&#8217;s dependencies for you.</p>
<p style="text-align: left;"><strong>Creating the App</strong></p>
<p style="text-align: left;">To create the hello world application we need just two classes. The first one is a configuration that tells the framework what to do. In our case it should tell the framework that we want a Tabris UI with only one page. This should look like this:</p>

&lt;pre lang=&quot;java&quot;&gt;
public class Configuration implements ApplicationConfiguration {

  @Override
  public void configure(Application application) {
    TabrisClientInstaller.install(application);
    application.addEntryPoint(&quot;/hello&quot;, new TabrisUIEntrypointFactory(createConfiguration()), null);
  }

  private UIConfiguration createConfiguration() {
    UIConfiguration uiConfiguration = new UIConfiguration();
    PageConfiguration startPageConfig = new PageConfiguration(&quot;root&quot;, StartPage.class);
    startPageConfig.setTopLevel(true);
    startPageConfig.setTitle(&quot;Hello World&quot; );
    uiConfiguration.addPageConfiguration(startPageConfig);
    return uiConfiguration;
  }

}
&lt;/pre&gt;

<p style="text-align: left;">After the configuration is complete, we will need a page. I decided to go with an easy one <img src='http://eclipsesource.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt="icon wink How to Bootstrap a Tabris Application with Maven and Eclipse" class='wp-smiley' title="How to Bootstrap a Tabris Application with Maven and Eclipse" /> . It&#8217;s just a pink colored page that does nothing.</p>

&lt;pre lang=&quot;java&quot;&gt;
public class StartPage extends AbstractPage {

  @Override
  public void createContent(Composite parent, PageData data) {
    parent.setBackground(new Color(parent.getDisplay(), 255, 150, 255));
  }

}
&lt;/pre&gt;

<p style="text-align: left;">Basically this is the whole application we want to create.</p>
<p style="text-align: left;"><strong>Configure the Web-Application</strong></p>
<p style="text-align: left;">One last step is to configure the Web-Application. We need to tell the Application that it should use the ApplicationConfiguration created in the previous step. We can do this by modifying the web.xml. You can find this file within your project by expanding the <em>&#8220;WebContent/WEB-INF&#8221;</em> folder. The content of the web.xml should look like this:</p>

&lt;pre lang=&quot;xml&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot; version=&quot;3.0&quot;&gt;
  &lt;context-param&gt;
    &lt;param-name&gt;org.eclipse.rap.applicationConfiguration&lt;/param-name&gt;
    &lt;param-value&gt;com.eclipsesource.hello.world.Configuration&lt;/param-value&gt;
  &lt;/context-param&gt;
 
  &lt;listener&gt;
    &lt;listener-class&gt;org.eclipse.rap.rwt.engine.RWTServletContextListener&lt;/listener-class&gt;
  &lt;/listener&gt;
 
  &lt;servlet&gt;
    &lt;servlet-name&gt;rwtServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.eclipse.rap.rwt.engine.RWTServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
 
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;rwtServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
&lt;/web-app&gt;
&lt;/pre&gt;

<p style="text-align: left;"><strong>Export</strong></p>
<p style="text-align: left;">That&#8217;s it! Our application is ready to be exported. You can do this by right clicking on your project and selecting <em>&#8220;Export&#8221; -&gt; &#8220;WAR-file&#8221;</em>.</p>
<p style="text-align: left;"><img class="aligncenter" alt="export How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/export.png" width="495" height="684" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;">After you have the .war file ready you can deploy it to whatever servlet container you want.</p>
<p style="text-align: left;"><strong>Access the Application</strong></p>
<p style="text-align: left;">To access the application you need a Tabris mobile client. You can download them from the <a href="http://developer.eclipsesource.com/tabris/downloads/">Tabris download page</a>. I have used the iOS client and the application looks like the one in the screenshot below. You need to point your client to your server, e.g. http://localhost:8080/com.eclipsesource.hello.world/hello (Please Note: Maybe you have to replace localhost with the address of your servlet container. On Android devices localhost points to the device.).</p>
<p style="text-align: left;"><img class="aligncenter" alt="hello How to Bootstrap a Tabris Application with Maven and Eclipse" src="http://download.eclipsesource.com/~hstaudacher/m2e-tabris/hello.png" width="396" height="744" title="How to Bootstrap a Tabris Application with Maven and Eclipse" /></p>
<p style="text-align: left;">If you have any open questions please don&#8217;t hesitate to leave a comment.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=How+to+Bootstrap+a+Tabris+Application+with+Maven+and+Eclipse&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/&amp;t=How+to+Bootstrap+a+Tabris+Application+with+Maven+and+Eclipse" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/#comments">3 Comments</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/java/' title='Java Tag'>Java</a>, <a href='http://eclipsesource.com/blogs/tag/maven/' title='maven Tag'>maven</a>, <a href='http://eclipsesource.com/blogs/tag/mobile/' title='mobile Tag'>mobile</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a>, <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/java/' title='Java Tag'>Java</a>, <a href='http://eclipsesource.com/blogs/tag/maven/' title='maven Tag'>maven</a>, <a href='http://eclipsesource.com/blogs/tag/mobile/' title='mobile Tag'>mobile</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/05/14/how-to-bootstrap-a-tabris-application-with-maven-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to use multiple browser tabs in your RAP 2.1 Application</title>
		<link>http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/</link>
		<comments>http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/#comments</comments>
		<pubDate>Fri, 10 May 2013 09:26:37 +0000</pubDate>
		<dc:creator>Tim Buschtöns</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[kepler]]></category>
		<category><![CDATA[new and noteworthy]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=15710</guid>
		<description><![CDATA[You can now download RAP 2.1 M2, the final milestone of RAP before the 2.1 (Kepler) release in June. This milstone adds quite a few nice features like bézier curves for Canvas, background-position and -repeat for CSS theming, and (especially) improved multi-tab browsing: It is now possible to host multiple UI-Sessions within the same HTTP-Session, <a href="http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>You can now <a href="http://eclipse.org/rap/downloads/">download RAP 2.1 M2</a>, the final milestone of RAP before the 2.1 (Kepler) release in June.</p>
<p>This milstone adds quite a few <a href="http://eclipse.org/rap/noteworthy/2.1/?build=M2">nice features</a> like bézier curves for Canvas, background-position and -repeat for CSS theming, and (especially) improved <b>multi-tab browsing</b>: It is now possible to host multiple UI-Sessions within the same HTTP-Session, meaning that there are no more tricks required to use multiple tabs with RAP applications in the same browser. Lets look at an example how multiple browser tabs can be used within a RAP application by integrating it with the <a href="http://eclipse.org/rap/developers-guide/devguide.php?topic=markup.html&#038;version=2.0#markup">markup</a> and <a href="http://eclipse.org/rap/developers-guide/devguide.php?topic=navigation.html&#038;version=2.0">BrowserNavigation</a> features. </p>
<p>Assuming our application lets the user select a person from a database to edit, the typical setup would be a TableViewer that opens a Dialog on a DefaultSelection event. We want to give the user the additional option to open this dialog in a new browser tab. This tab may run the same EntryPoint, or in this case one designed for this specific purpose only. </p>
<p><img src="http://download.eclipsesource.com/~tbuschto/multitab.png" title="How to use multiple browser tabs in your RAP 2.1 Application" alt="multitab How to use multiple browser tabs in your RAP 2.1 Application" /></p>
<p>We create a TableViewer with markup support:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">viewer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TableViewer<span style="color: #009900;">&#40;</span> parent <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
viewer.<span style="color: #006633;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setData</span><span style="color: #009900;">&#40;</span> RWT.<span style="color: #006633;">MARKUP_ENABLED</span>, <span style="color: #003399;">Boolean</span>.<span style="color: #000066; font-weight: bold;">TRUE</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Then we insert a link in the last cell of each row, whereby &#8220;edit&#8221; is the name of another EntryPoint:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">viewer.<span style="color: #006633;">setLabelProvider</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> CellLabelProvider<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> update<span style="color: #009900;">&#40;</span> ViewerCell cell <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Person person <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> Person <span style="color: #009900;">&#41;</span>cell.<span style="color: #006633;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span> cell.<span style="color: #006633;">getColumnIndex</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">case</span> COLUMN_FIRST_NAME<span style="color: #339933;">:</span>
        cell.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span> person.<span style="color: #006633;">name</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">case</span> COLUMN_PLACE_OF_BIRTH<span style="color: #339933;">:</span>
        cell.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span> person.<span style="color: #006633;">nation</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">case</span> COLUMN_LINKS<span style="color: #339933;">:</span>
        <span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;edit#person/&quot;</span> <span style="color: #339933;">+</span> persons.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span> person <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        cell.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>  
          <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> 
          <span style="color: #339933;">+</span> url 
          <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> target=<span style="color: #000099; font-weight: bold;">\&quot;</span>_blank<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;edit&lt;/a&gt;&quot;</span> 
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In the other EntryPoint, we add deep-link support like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">BrowserNavigation bn 
  <span style="color: #339933;">=</span> RWT.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getService</span><span style="color: #009900;">&#40;</span> BrowserNavigation.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
bn.<span style="color: #006633;">addBrowserNavigationListener</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> BrowserNavigationListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> navigated<span style="color: #009900;">&#40;</span> BrowserNavigationEvent event <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> state <span style="color: #339933;">=</span> event.<span style="color: #006633;">getState</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> state.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;person/&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">int</span> index <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span> state.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">7</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      editPerson<span style="color: #009900;">&#40;</span> persons.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span> index <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Done. You could also use the <a href="http://eclipse.org/rap/developers-guide/devguide.php?topic=navigation.html&#038;version=2.0#launcher">URLLauncher</a> service to open the tab without using a &#8220;real&#8221; link.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=How+to+use+multiple+browser+tabs+in+your+RAP+2.1+Application&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/&amp;t=How+to+use+multiple+browser+tabs+in+your+RAP+2.1+Application" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/#comments">2 Comments</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/kepler/' title='kepler Tag'>kepler</a>, <a href='http://eclipsesource.com/blogs/tag/new-and-noteworthy/' title='new and noteworthy Tag'>new and noteworthy</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a>, <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/kepler/' title='kepler Tag'>kepler</a>, <a href='http://eclipsesource.com/blogs/tag/new-and-noteworthy/' title='new and noteworthy Tag'>new and noteworthy</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/05/10/rap-2-1-m2-multi-browser-tabs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>When an exception gets lost</title>
		<link>http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/</link>
		<comments>http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/#comments</comments>
		<pubDate>Thu, 25 Apr 2013 10:06:45 +0000</pubDate>
		<dc:creator>Tillmann Seidel</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=15529</guid>
		<description><![CDATA[Recently I fell into the lost exception pitfall &#8211; when an exception thrown in a try block gets lost because another exception is thrown in the finally block. It wasn&#8217;t that I was not aware of the problem, but rather that I underestimated and therefore ignored it. This post describes an example where suppressed exceptions <a href="http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 330px"><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/6947296049_a513bdfc32_n.jpg"><img alt="6947296049 a513bdfc32 n When an exception gets lost" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/6947296049_a513bdfc32_n.jpg" width="320" height="213" title="When an exception gets lost" /></a><p class="wp-caption-text">Image via CC from <a href="http://www.flickr.com/photos/gorbould/6947296049/" target="_blank">Paul Gorbould</a></p></div>
<p>Recently I fell into the <a href="http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ311_014.htm" target="_blank">lost exception pitfall</a> &#8211; when an exception thrown in a <code>try</code> block gets lost because another exception is thrown in the <code>finally</code> block. It wasn&#8217;t that I was not aware of the problem, but rather that I underestimated and therefore ignored it. This post describes an example where suppressed exceptions have fatal consequences, and describes possible solutions, one of them using Java 7&#8242;s try-with-resources.</p>
<h2>The trap</h2>
<p>Our web application is based on the <a href="http://developer.eclipsesource.com/technology/crossplatform/#rap" target="_blank">Eclipse Remote Application Platform (RAP)</a>. The main loop of the session thread is wrapped into a <code>try</code> block, cleanup is done in the <code>finally</code> block. When the session times out, a <code>java.lang.Error</code> (more precisely, a <code>java.lang.TreadDeath</code>) is thrown from within the while loop:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">// main loop</span>
   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>done<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// when the session times out, an error is thrown here</span>
      ...
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">// there is a bug in this method, causing a </span>
   <span style="color: #666666; font-style: italic;">// NullPointerException to be thrown</span>
   cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Unfortunately the <code>cleanup</code> method was programmed sloppily and sometimes causes a <code>NullPointerException</code>. In that case the <code>Error</code> is swallowed and the <code>NullPointerException</code> is propagated instead. </p>
<p>In our case this leads to the situation where the session cannot be terminated correctly, resulting in a memory leak. This effect is similar to catching <code>Throwable</code> in application code as described in <a href="http://eclipsesource.com/blogs/2012/08/08/to-catch-or-not-to-catch-throwable/" target="_blank">Ivan Furnadjiev&#8217;s post</a>. Our case is even worse since the error is swallowed without a trace &#8211; when <code>Throwable</code> is caught, there is at least a slim chance of finding it in a log.</p>
<p>The situation described above is an example of a well-known problem in Java called <b>suppressed</b>, <strong>lost</strong> or <strong>masked exception</strong>.</p>
<h2>Solution 1: Handle exceptions in the finally block and never let them out</h2>
<p>Proposed for example, in the <a href="https://today.java.net/article/2006/04/04/exception-handling-antipatterns#catchingException" target="_blank">Exception-Handling Antipatterns</a>, this solution handles exceptions in the <code>finally</code> block but never propagates them. The exception thrown in the <code>try</code> block is the only one visible to the outside.<br />
For our use case, logging the exceptions is a proper handling:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      log.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This solution is easy and quite readable, but the exceptions in the <code>finally</code> block are not available anymore for processing outside of this scope.</p>
<h2>Solution 2: Collect all exceptions in a wrapper exception</h2>
<p>The idea is to collect all exceptions occurring in the <code>try</code> and <code>finally</code> blocks, and to attach them to a single exception which is thrown in the end.<br />
<a href="http://accu.org/index.php/journals/236" target="_blank">This article</a> shows several code snippets on how to achieve that. This solution preserves all exceptions, but if you look at the article, you can see that the code quickly becomes unreadable and therefore unmaintainable.</p>
<h2>Solution 3: Java 7 to the rescue</h2>
<p>The <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions" target="_blank">try-with-resources</a> statement introduced in Java 7 preserves suppressed exceptions <b>and</b> has a short and readable syntax. Exceptions formerly thrown in the <code>finally</code> block are automatically attached as suppressed exceptions to the <code>Throwable</code> thrown in the <code>try</code> block. The cleanup code has to be wrapped into the <code>close</code> method of a class which implements the <code>AutoCloseable</code> interface:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Cleanup <span style="color: #000000; font-weight: bold;">implements</span> AutoCloseable <span style="color: #009900;">&#123;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
...
&nbsp;
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>Cleanup cleanup <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>done<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ...
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The <code>Error</code> is now propagated properly, with the <code>NullPointerException</code> as a suppressed exception. Note that this is a simplified version of the <code>close</code> method &#8211; it should not suppress <code>Exception</code> in general but rather filter out relevant ones (see the <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html" target="_blank">JavaDoc of the close method</a> for details). </p>
<p>If the <a href="http://www.oracle.com/technetwork/java/eol-135779.html" target="_blank">Java 6 end of life</a> did not convince you to migrate to Java 7, maybe the try-with-resources will.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=When+an+exception+gets+lost&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/&amp;t=When+an+exception+gets+lost" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/#comments">1 Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/java/' title='Java Tag'>Java</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a>, <a href='http://eclipsesource.com/blogs/tag/java/' title='Java Tag'>Java</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/04/25/when-an-exception-gets-lost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tabris 1.0 is here!</title>
		<link>http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/</link>
		<comments>http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 08:55:55 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[new and noteworthy]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[Tabris]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=15384</guid>
		<description><![CDATA[Today we are proud to release Tabris 1.0. If you have not followed us so far you probably don&#8217;t know what Tabris is. Let me put it in one sentence: Tabris is the first Java-Toolkit for the cross-platform development of native mobile Apps. It enables you to write iOS and Android Apps completely in Java with <a href="http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.eclipsesource.com/tabris/"><img class="size-full wp-image-15402 alignright" alt="tabris logo Tabris 1.0 is here!" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/tabris-logo.png" width="325" height="236" title="Tabris 1.0 is here!" /></a>Today we are proud to release <a href="http://developer.eclipsesource.com/tabris/">Tabris 1.0</a>. If you have not followed us so far you probably don&#8217;t know what Tabris is. Let me put it in one sentence: Tabris is the first Java-Toolkit for the cross-platform development of native mobile Apps. It enables you to write iOS and Android Apps completely in Java with a single code base. With this post, I want to sum up our journey till now and show you which features have made it into the 1.0 release.</p>
<p>Tabris sits on top of <a href="http://eclipse.org/rap/">Eclipse RAP</a>. RAP provides a UI Toolkit to write Web applications using Java. This UI Toolkit is based on Widgets, so you don&#8217;t have to mess around with HTML. To be able to display those widgets in a browser, RAP uses a protocol which is based on JSON. Within this protocol are messages that instruct the browser e.g. to display a button, or a tree, and so on. What Tabris does is to provide two alternative clients which are an iOS and an Android client. Those clients simply understand the RAP protocol messages and display widgets using the native counterparts.</p>
<p>On <a href="http://eclipsesource.com/blogs/2010/04/28/rap-2-0-protocol/">April 28th, 2010</a> we have previewed a version of the RAP protocol which basically marked the start of Tabris internally. Two months later (<a href="http://eclipsesource.com/blogs/2010/06/11/writing-ipadiphoneipod-applications-with-swt/">June 11th, 2010</a>), we had the first working prototype which has used Apple&#8217;s iAd JavaScript framework for rendering. Since then we have worked on what is today released as Tabris. It includes two native clients and an extension of the server side RAP API. This extension, which is just another jar, is necessary because the RAP API is based on the Standard Widget Toolkit (SWT). SWT is limited when it is used on mobile devices. There are no APIs for Geolocation, Camera and other things a mobile App typically use.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/tabris-mdevices.png"><img class="alignright size-full wp-image-15407" alt="tabris mdevices Tabris 1.0 is here!" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/tabris-mdevices.png" width="302" height="370" title="Tabris 1.0 is here!" /></a>The first time we made our mobile clients public was the start of our &#8220;developer preview&#8221; back in <a href="http://eclipsesource.com/blogs/2012/01/31/rap-mobile-ios-and-android-apps-written-in-java/">January 31st, 2012</a>. At this time we concentrated on implementing a proper support for the SWT widgets. Since then, we have released <a href="https://github.com/eclipsesource/tabris/issues/milestones?state=closed">14 milestones</a>. The last public milestone was tagged with <a href="http://eclipsesource.com/blogs/2013/02/18/tabris-0-11-0-new-noteworthy/">0.11.0</a>. We think that this was the most important one for Tabris. It introduced a feature called the <a href="http://eclipsesource.com/blogs/2013/02/19/inside-the-tabris-ui/">Tabris UI</a>. Tabris UI is a higher level API for creating a frame for your mobile application. The native clients use native navigation concepts to display a Tabris UI-based application. On Android this is the ActionBar and on iOS these are the ViewControllers. So, since Tabris 0.11.0 it has been possible to write native applications using native Widgets combined with native navigation concepts.</p>
<p>In the last weeks we have concentrated on Bug fixing and API cleanup to ship a release we can be proud of. If you would like to try out Tabris yourself, just <a href="http://developer.eclipsesource.com/tabris/downloads/">download the 30 day trial version</a>. This trial has no functional limitations! To get started with this trial we have created some detailed <a href="http://developer.eclipsesource.com/tabris/docs/">getting started guides</a> you can use. We have also created a <a href="http://developer.eclipsesource.com/tabris/demos/">bunch of screencasts</a> that show some of the features Tabris provides. You can find the new &amp; noteworthy articles so far below:</p>
<ul>
<li><a href="http://eclipsesource.com/blogs/2012/02/27/rap-mobile-for-android-0-5-3-new-and-noteworthy/">Tabris 0.5.3</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/03/14/rap-mobile-0-5-4-new-and-noteworthy/">Tabris 0.5.4</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/03/30/rap-mobile-0-5-5-new-and-noteworthy/">Tabris 0.5.5</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/04/11/rap-mobile-0-5-6-new-and-noteworthy/">Tabris 0.5.6</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/05/02/rap-mobile-0-5-7-new-and-noteworthy/">Tabris 0.5.7</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/05/15/rap-mobile-0-5-8-new-and-noteworthy/">Tabris 0.5.8</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/06/20/tabris-0-6-0-new-and-noteworthy/">Tabris 0.6.0</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/07/13/tabris-0-6-1-new-and-noteworthy/">Tabris 0.6.1</a></li>
<li><a href="https://github.com/eclipsesource/tabris/issues?milestone=1&amp;state=closed">Tabris 0.6.2</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/09/06/tabris-0-7-0-new-and-noteworthy/">Tabris 0.7.0</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/10/19/tabris-0-8-0-new-and-noteworthy/">Tabris 0.8.0</a></li>
<li><a href="http://eclipsesource.com/blogs/2012/12/18/tabris-0-9-0-new-noteworthy/">Tabris 0.9.0</a></li>
<li><a href="http://eclipsesource.com/blogs/2013/01/17/tabris-0-10-0-new-noteworthy/">Tabris 0.10.0</a></li>
<li><a href="http://eclipsesource.com/blogs/2013/02/18/tabris-0-11-0-new-noteworthy/">Tabris 0.11.0</a></li>
</ul>
<p>At this point I want to thank the community which has provided us with great feedback, feature requests and bug reports. I also want to thank the rest of the Tabris team: <a href="http://eclipsesource.com/blogs/author/jordi/">Jordi Böhme López</a>, <a href="http://eclipsesource.com/blogs/author/jeick/">Johannes Eickhold</a>, <a href="http://eclipsesource.com/blogs/author/mpost/">Moritz Post</a> and <a href="http://eclipsesource.com/blogs/author/ivan/">Ivan Furnadjiev</a> for doing a great job over the last year! And last but not least, many thanks to the <a href="http://projects.eclipse.org/projects/rt.rap">Eclipse RAP team</a> for their great support!</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Tabris+1.0+is+here%21&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/&amp;t=Tabris+1.0+is+here%21" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/#comments">8 Comments</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/android/' title='android Tag'>android</a>, <a href='http://eclipsesource.com/blogs/tag/ios/' title='iOS Tag'>iOS</a>, <a href='http://eclipsesource.com/blogs/tag/new-and-noteworthy/' title='new and noteworthy Tag'>new and noteworthy</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a>, <a href='http://eclipsesource.com/blogs/tag/android/' title='android Tag'>android</a>, <a href='http://eclipsesource.com/blogs/tag/ios/' title='iOS Tag'>iOS</a>, <a href='http://eclipsesource.com/blogs/tag/new-and-noteworthy/' title='new and noteworthy Tag'>new and noteworthy</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/04/16/tabris-1-0-is-here/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The D.I.Y. RAP Client Construction Kit</title>
		<link>http://eclipsesource.com/blogs/2013/04/12/rap-lite/</link>
		<comments>http://eclipsesource.com/blogs/2013/04/12/rap-lite/#comments</comments>
		<pubDate>Fri, 12 Apr 2013 13:01:58 +0000</pubDate>
		<dc:creator>Tim Buschtöns</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[eclipseRT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[Single Sourcing]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=15155</guid>
		<description><![CDATA[Since RAP 2.0 has fully implemented the JSON-based RAP Protocol I was eager to test it&#8217;s full potential myself. The Tabris clients for Android and iOS already exist and others may follow, but as I&#8217;m mostly at home in the browser that&#8217;s where I would like to use it. The Vision My idea was to <a href="http://eclipsesource.com/blogs/2013/04/12/rap-lite/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Since RAP 2.0 has <a href="http://eclipsesource.com/blogs/2012/10/05/rap-2-0-m2-json-protocol-migration-complete/">fully implemented</a> the JSON-based <a href="http://wiki.eclipse.org/RAP/Protocol">RAP Protocol</a> I was eager to test it&#8217;s full potential myself. The <a href="http://eclipsesource.com/en/products/tabris/">Tabris</a> clients for Android and iOS already exist and others may follow, but as I&#8217;m mostly at home in the browser that&#8217;s where I would like to use it.</p>
<h2>The Vision</h2>
<p>My idea was to create a highly modular and especially flexible client that supports only a minimal subset of RAP features, but can very easily be extended and customized. RAP 2.0 introduced a simple JavaScript API for creating custom widgets. This client would go one step further and also allow you to change the presentation of existing widgets to your liking (also using JavaScript). For that you don&#8217;t have to implement a new Java API, the client-server communication is already in place, as is the internal logic of the widget (like selection management). Also, the widget will still be single-sourcing capable. Any RAP widgets or features that you might miss in the client you should easily be able to implement yourself after reading the documentation. It would basically be a D.I.Y. RAP Client construction kit, and not a replacement for the full-blown existing WebClient.</p>
<p>Another noticeable feature of this client would also be its ability to adapt to (and take advantage of) different environments. This would also mean that it breaks with RAPs paradigm of looking and working identically on all supported browsers. If you want to take advantage of exciting HTML5/CSS3 features you can but it won&#8217;t work/look like the same older browser. You could also create a very different presentation if you are on a touchscreen device, or if you want to optimize for performance on older hardware. You could even create a presentation built entirely on SVG, or for other environments than a browser, as long as they run JavaScript.</p>
<p>By the way, most custom widgets and ClientScripting components written for the default WebClient should also still work with this client.</p>
<p>So I went ahead and built a <b>proof-of-concept/experimental</b> version of this web client for RAP. It currently supports 5 widgets and is appropriately titled &#8220;RAP Lite&#8221;. The code can be viewed <a href="https://github.com/tbuschto/rap-lite">here</a>. You can also download it and run the demo but remember that this is strictly a research project and only barely functional.</p>
<h2>What can it currently do?</h2>
<p>First of all, here are two screenshots of the <strong>Demo</strong> application included:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/rap-lite-vs1.png"><img class="aligncenter size-full wp-image-15269" alt="rap lite vs1 The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/rap-lite-vs1.png" width="647" height="325" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>The screenshot on the left is the default WebClient, while the one on the right is RAP Lite. The first 5 buttons all only change the Label at the top.<br />
So far it looks and works mainly in the same way, except that RAP Lite starts up faster.</p>
<p>&#8220;Visit the other side&#8221; brings a List widget to the front using a nice CSS3 animation in the latest FireFox and Chrome browsers:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/ani.png"><img class="aligncenter size-full wp-image-15273" alt="ani The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/ani.png" width="600" height="461" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>Clicking on &#8220;Scroll&#8221; will animate the scroll position of the List to a random value. In a modern browser the scrollbar is a subwidget (iScroll) that looks the same on any OS. Let&#8217;s compare that with IE8:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/scrollbars.png"><img class="aligncenter size-full wp-image-15275" alt="scrollbars The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/scrollbars.png" width="601" height="331" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>In IE (on the right), the List now uses the traditional OS-native scrollbar without animation because the iScroll widget is not supported in IE. Also, the gradients are gone because RAP Lite will not go to the same lengths as the default client to render them. Lets modify the demo to tell the client to use another presentation for buttons:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/win7buttons.png"><img class="aligncenter size-full wp-image-15278" alt="win7buttons The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/win7buttons.png" width="286" height="312" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>Now RAP Lite uses the native HTML form elements for push buttons, which aren&#8217;t as flexible, but look somewhat better than flat rectangles.</p>
<p>Finally, lets have a look at a cool feature that I didn&#8217;t mention before at all: The ability to run RAP Lite inside of a traditional, static HTML website:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/raplite-website.png"><img class="aligncenter size-full wp-image-15281" style="border: 1px solid black; padding: 3px;" alt="raplite website The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/raplite-website.png" width="653" height="512" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>This is not RAP running in an iframe. Instead, there is a simple script within that static HTML site that assigns the RAP application a div to run in. However, that&#8217;s not all. Let&#8217;s assume you want to embedd RAP in your website, with some static content <i>between</i> the RAP components. You can do that too. The button at the bottom of the demo opens another Shell which now looks like this:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/raplite-website2.png"><img class="aligncenter size-full wp-image-15282" style="border: 1px solid black; padding: 3px;" alt="raplite website2 The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/raplite-website2.png" width="650" height="514" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>Notice that the text flows around the new Shell, and even adapts when it changes it size.</p>
<h2>How does it work?</h2>
<p>RAP Lite can be separated into three layers (+libaries):</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/architecture.png"><img class="aligncenter size-full wp-image-15197" alt="architecture The D.I.Y. RAP Client Construction Kit" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/04/architecture.png" width="1449" height="442" title="The D.I.Y. RAP Client Construction Kit" /></a></p>
<p>The first layer provides the core infrastructure for communicating with a RAP server. The code is taken directly from the existing WebClient and could be used to build any kind of JavaScript-based RAP client on top. (This is not quite the case yet, but almost).</p>
<p>The second layer provides the widget data models and internal logic, and connects the models with the first layer. It does not, however, include any HTML/CSS rendering or DOM event handling. As such it should, like the first layer, be able to run in any JavaScript environment, even non-browser.</p>
<p>The third and final layer does the actual presentation. Each widget model is assigned one <b>or more</b> (alternative) views that can render their content. The views use HTML templates and/or subwidgets (standalone widgets not based on a model) to generate the widget representation. DOM Events are pre-processed by the view, then forwarded to the model. The theming is applied using central CSS rules generated at runtime, and every view can contribute it&#8217;s own rules. Most changes in the model are either reflected by adding/removing CSS classes, or by re-rendering all or most of the HTML. While more incremental changes may be more efficient in some cases, this approach keeps the code very simple and the number of DOM operations small.</p>
<p><span style="font-size: 1.5em;">What does it all mean?</span></p>
<p>There are currently no concrete plans for a more &#8220;official&#8221; version of this client. The fact that is&#8217;s based on underscore.js sadly means that it can not become part of the RAP project for legal reasons. However, if I&#8217;m ever involved in creating another web client for RAP, it will most likely look a lot like this experiment.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=The+D.I.Y.+RAP+Client+Construction+Kit&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/04/12/rap-lite/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/04/12/rap-lite/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/04/12/rap-lite/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/04/12/rap-lite/&amp;t=The+D.I.Y.+RAP+Client+Construction+Kit" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/04/12/rap-lite/#comments">Leave a Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/eclipsert/' title='eclipseRT Tag'>eclipseRT</a>, <a href='http://eclipsesource.com/blogs/tag/javascript/' title='javascript Tag'>javascript</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/single-sourcing/' title='Single Sourcing Tag'>Single Sourcing</a>, <a href='http://eclipsesource.com/blogs/tag/eclipsert/' title='eclipseRT Tag'>eclipseRT</a>, <a href='http://eclipsesource.com/blogs/tag/javascript/' title='javascript Tag'>javascript</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/single-sourcing/' title='Single Sourcing Tag'>Single Sourcing</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/04/12/rap-lite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing JavaScript Tests with Jasmine for RAP</title>
		<link>http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/</link>
		<comments>http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/#comments</comments>
		<pubDate>Tue, 02 Apr 2013 08:44:35 +0000</pubDate>
		<dc:creator>Tim Buschtöns</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=14233</guid>
		<description><![CDATA[If you are writing unit tests for your Java code, then you should also write them for any other code you wrote for the same project. Otherwise these tests only give you a false sense of security. RAP 2.0 provides a new JavaScript API to extend the framework with custom components, as you can read <a href="http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-14336 alignright" alt="rapjasmine trnsp Writing JavaScript Tests with Jasmine for RAP" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/02/rapjasmine_trnsp.png" width="356" height="240" title="Writing JavaScript Tests with Jasmine for RAP" /></p>
<p>If you are writing unit tests for your Java code, then you should also write them for any other code you wrote for the same project. Otherwise these tests only give you a false sense of security. RAP 2.0 provides a new JavaScript API to extend the framework with custom components, as you can read <a href="http://eclipsesource.com/blogs/2013/02/11/rap-2-0-countdown-55/">here</a>. Using third party JavaScript libaries (<a href="http://jquery.com/">jQuery</a>, <a href="http://d3js.org/">D3</a>, etc) or widgets/applications (like <a href="http://rap.eclipsesource.com/rapdemo/examples#gmaps">GMaps</a>, <a href="http://ckeditor.com/demo">CKEditor</a>&#8230; ) makes the task manageable even if you are not an HTML/CSS/JavaScript expert. But what about tests?</p>
<p>As Java/RCP/RAP developer you may be used to JUnit, and perhaps Mockito (if not: read <a href="http://eclipsesource.com/blogs/2011/09/19/effective-mockito-part-1/">this</a>). Now, Java/JavaScript differences aside, I like <a href="http://pivotal.github.com/jasmine/">Jasmine</a> even better. I used it to test my JavaScript code when porting the CKEditor add-on for RAP (<a href="http://rap.eclipsesource.com/rapdemo/examples#ckeditor">demo</a>, <a href="https://github.com/eclipsesource/rap-ckeditor">download</a>) to RAP 2.0. In this article I will use this project to demonstrate one way to use Jasmine with RAP.<br />
You can look at the editors <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor/src/com/eclipsesource/widgets/ckeditor/CKEditor.java">Java implementation</a> here, and at the <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor/src/resources/handler.js">JavaScript code</a> we want to test here.</p>
<h3>Remote API Basics</h3>
<p>To fully understand the examples i&#8217;ll show here, you should be familiar with the RAP Remote API, but you&#8217;ll get the gist of it either way. If you want, you can jump straight to the next chapter.</p>
<p>A brief introduction to Remote API is also given <a href="http://eclipsesource.com/blogs/2013/02/11/rap-2-0-countdown-55/">here</a>. Basically, each side (client and server) have one &#8220;half&#8221; of the custom widget, and a representation of the other side&#8217;s &#8220;half&#8221; as an instance of <code>RemoteObject</code>:</p>
<p><a href="http://eclipsesource.com/blogs/2013/02/01/rap-2-0-countdown-15/"><img class="aligncenter size-full wp-image-14008" alt="half objects Writing JavaScript Tests with Jasmine for RAP" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/02/half-objects.png" width="601" height="215" title="Writing JavaScript Tests with Jasmine for RAP" /></a></p>
<p>Therefore RAP includes a <code>RemoteObject</code> <a href="http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/api/org/eclipse/rap/rwt/remote/RemoteObject.html">implementation for Java</a> and <a href="http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/jsdoc/symbols/RemoteObject.html">one for JavaScript</a>. The main difference is that the server can create new remote objects&#8230;</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Connection</span> connection <span style="color: #339933;">=</span> RWT.<span style="color: #006633;">getUISession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">RemoteObject</span> remoteObject 
  <span style="color: #339933;">=</span> connection.<span style="color: #006633;">createRemoteObject</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;MyWidget&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>&#8230; while the client can only get existing ones:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #000066; font-weight: bold;">var</span> remoteObject <span style="color: #339933;">=</span> rap.<span style="color: #660066;">getRemoteObject</span><span style="color: #009900;">&#40;</span> widgetInstance <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>In addition, the Server can also <a href="http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/api/org/eclipse/rap/rwt/remote/RemoteObject.html#setHandler%28org.eclipse.rap.rwt.remote.OperationHandler%29"> receive remote operations</a> via the remote object, while the client object has to implement methods (especially setter) that can be directly called by the framework.</p>
<p>Typically, a simple custom widgets client-side life cycle looks like this:</p>
<ul>
<li id="typehandler">The client component has to <a href="http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/jsdoc/symbols/rap.html#.registerTypeHandler">register a TypeHandler</a> (once). This is basically the glue between your custom widget and the framework. The type handler consist of a factory for the client object, and a list of properties, methods and events it supports.</li>
<li>The server side creates an <code>RemoteObject</code> instance. With this, a &#8220;create&#8221; operation is send to the client and invokes the type handler&#8217;s factory.</li>
<li>Using the id of a <code>Composite</code> (which the server typically provides in a &#8220;set&#8221; operation), the custom widget can obtain the client side instance and attach itself to it: <code style="white-space: nowrap;">rap.getObject( parentId ).append( htmlElement );</code></li>
<li>All invocations of &#8220;set&#8221; or &#8220;call&#8221; on the server side <code>RemoteObject</code> will cause the matching methods of the client widget to be called. To send messags back, the client widget can itself obtain a <code>RemoteObject</code> to send operations to the server.</li>
<li>When the server remote object is destroyed, so is the client object.</li>
</ul>
<h3>Jasmine at a glance</h3>
<p>The Jasmine project site already gives a good <a href="http://pivotal.github.com/jasmine/">tutorial</a>, so I&#8217;ll try to keep this short. Jasmine allows for Behavior-Driven Development (BDD), which is similar to Test-Driven Development (TDD). It basically means that your tests will read <a href="http://en.wikipedia.org/wiki/Behavior-driven_development#Behavioral_specifications">like a &#8220;story&#8221;</a> written in plain English. (Or any other language, <a href="http://eclipsesource.com/blogs/2012/09/03/js-i18n/">if you&#8217;re crazy</a>.)</p>
<p>For example, a traditional test in JUnit&#8230;</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Math_Test <span style="color: #000000; font-weight: bold;">extends</span> TestCase
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> test_RoundsUp2Point5<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    assertEquals<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">3</span>, <span style="color: #003399;">Math</span>.<span style="color: #006633;">round</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">2.5</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>&#8230; may look like this in Jasmine:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">describe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Math&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  it<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;should round 2.5 to 3&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    expect<span style="color: #009900;">&#40;</span> <span style="">Math</span>.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">2.5</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toBe</span><span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">3</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>As you can see it&#8217;s not that different at first, except it&#8217;s easier to describe what exactly you are testing. The &#8220;describe&#8221; function seems similar to a test class (it is called a &#8220;Suite&#8221;), &#8220;it&#8221; to a test method (actually a &#8220;Spec&#8221;), and &#8220;expect&#8221; looks a bit like Mockitos &#8220;verify&#8221;. The &#8220;setUp&#8221; and &#8220;tearDown&#8221; methods in JUnit would be &#8220;beforeEach&#8221; and &#8220;afterEach&#8221; functions in Jasmine.</p>
<p>However, the advantage is that unlike JUnit tests, &#8220;describe&#8221; functions can be nested. And what I personally love about that, is that each can have it&#8217;s very own beforeEach/afterEach functions, and they are executed for all the &#8220;describe&#8221; functions the &#8220;it&#8221; is in. That made my tests a lot more readable. In JUnit I would often have a lot of similar setup code at the beginning for each test, and multiple asserts the end. Sure, there ways to reduce it, but I think it&#8217;s a pain. My Jasmine Specs on the other hand are usually around three lines only.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/02/jasminegraph.png"><img class="aligncenter size-full wp-image-14429" alt="jasminegraph Writing JavaScript Tests with Jasmine for RAP" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/02/jasminegraph.png" width="761" height="496" title="Writing JavaScript Tests with Jasmine for RAP" /></a></p>
<h3>What to test?</h3>
<p>There may be several parts to your JavaScript component. The RAP <a href="#typehandler">type handler</a> has little to no logic of it&#8217;s own, and would require a &#8220;real&#8221; RAP client to be tested. Therefore we omit it, and only test the widget <a href="http://en.wikipedia.org/wiki/Prototype-based_programming">&#8220;class&#8221;</a> itself.</p>
<p>If your custom widget is basically a wrapper for an existing JavaScript app (like CKEditor), then you might want to test <i>only</i> the wrapper. If so, you can also replace the app with your own mock, though you have to know the app&#8217;s API really well for that to work. In my case, I first did a untested prototype to figure out how to get the CKEditor to cooperate with RAP. Then I started again from scratch, writing tests first using a <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor.test/js/CKEditorMock.js">CKEditor mock</a> I created myself.</p>
<p>If you are writing the entire widget yourself, you should of course test all of it, not just the part that connects to RAP.</p>
<h3>Setting Up Jasmine with a RAP enviroment</h3>
<p>Download the Jasmine <a href="http://pivotal.github.com/jasmine/#section-Downloads">Standalone Release</a> and unzip it to a folder in your test project. You don&#8217;t need the included examples, so delete the <code>src</code> and <code>specs</code> folder. Open the <code>SpecRunner.html</code> in an editor. We are interested in the <code>&lt;script&gt;</code> tags only. Remove those that point to the deleted files. Then get the &#8220;<a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor.test/js/rap-mock.js">rap-mock.js</a> from our GitHub repository and include it with a new script tag. This is key, as the file contains a mock implementation of the RAP JavaScript API, so that your custom component can be tested outside an actual RAP application.</p>
<p><i>Below</i> the rap-mock.js, add the JavaScript file(s) from your own RAP JavaScript component. If they are in another bundle, it may have to look like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;script 
  type=&quot;text/javascript&quot; 
  src=&quot;../../com.eclipsesource.widgets.ckeditor/src/resources/handler.js&quot;&gt;
&lt;/script&gt;</pre></td></tr></table></div>

<p><span/><br />
Finally, create a new JavaScript file like &#8220;<a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor.test/js/specs/CKEditorSpec.js">CKEditorSpec.js</a>&#8221; and also include it in the HTML file. This is where we will put the tests.</p>
<p>The rap mock is initialized automatically by including the file itself, but to be sure that everything is reset with each test, your outmost &#8220;beforeEach&#8221; should look like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"> beforeEach<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  rap <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> RapMock<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>In addition to the <a href="http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/jsdoc/symbols/rap.html">official API of the &#8220;rap&#8221; object</a>, this one has two fields &#8220;fakeRemoteObject&#8221; and &#8220;fakeComposite&#8221;. Like &#8220;rap&#8221; itself, they are only empty implementations of the <code>RemoteObject</code> and <code>Composite</code> types, which are returned if <code>rap.getRemoteObject()</code> or <code>rap.getObject()</code> (respectively) are called. That makes it a lot easier to test interactions with these objects later on. (Note that it always returns the <i>same</i> instances, but since they dont have any state it shouldn&#8217;t matter.)</p>
<h3>My First Spec</h3>
<p>Since variables have function scope in JavaScript, and all Suites and Specs are functions, you can freely define variables within any suite and share them with the contained Specs. I would suggest to do so for your outmost Suite for the instance of your custom widget. For me, it looks like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">describe<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;eclipsesource.CKEditor&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">var</span> editor<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">var</span> createEditor <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    editor <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> eclipsesource.<span style="color: #660066;">CKEditor</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;parent&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;w2&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  beforeEach<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    rap <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> RapMock<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    editor <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  afterEach<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    editor <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  ...
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>I&#8217;m not creating an instance in the outer Suite because we will sometimes need to do some setup <i>before</i> calling the constructor. This is where <a href="https://github.com/pivotal/jasmine/wiki/Spies">spies</a> come into play. Remember, our rap mock (and in this case CKEditor mock) does absolutely nothing itself (except preventing crashes). To write meaningful tests, we need to spy on it.</p>
<p>Spies replace methods with stubs, which can later be checked for invocations Mockito-style. They can also return any value, capture arguments, or execute arbitrary code. Read more about them <a href="https://github.com/pivotal/jasmine/wiki/Spies">here</a>. Spies are automatically removed after each <code>it</code>.</p>
<p>Now we dive right into it, and test that the widget adds itself (specifically it&#8217;s element) to the parent:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">  describe<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;The Constructor&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    it<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;should get a Composite with the parent id&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      spyOn<span style="color: #009900;">&#40;</span> rap<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;getObject&quot;</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">andCallThrough</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      createEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      expect<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">getObject</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toHaveBeenCalledWith</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;w2&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    it<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;should add an element to the composite&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      spyOn<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">fakeComposite</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;append&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      createEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      expect<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">fakeComposite</span>.<span style="color: #660066;">append</span> <span style="color: #009900;">&#41;</span>
       .<span style="color: #660066;">toHaveBeenCalledWith</span><span style="color: #009900;">&#40;</span> editor.<span style="color: #660066;">element</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>It is a common pattern to prefix &#8220;private&#8221; fields of JavaScript objects with a &#8220;_&#8221;. For the CKEditor wrapper I completely abstained from creating private fields and made everything &#8220;public&#8221;, including the HTML element. If I hadn&#8217;t, I would either have to access a private field, or examine the contents of the element that was given to the fake composite. Since i&#8217;m not interested in testing the CKEditor itself, I chose this simpler solution.</p>
<p>Most other aspects of the constructor and the editor/wrapper are tested in similar ways, as you can read in the <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor.test/js/specs/CKEditorSpec.js">full Spec file</a>. However, there are a few more special cases I like to discuss in detail.</p>
<h3>Testing events</h3>
<p>The CKEditor wrapper registers events listener on the CKEditor itself and on the &#8220;rap&#8221; object, e.g. to check for changes before a request is send to the server. There are various ways to test them. The &#8220;cleanest&#8221; one would likely be to obtain the listener with a spy and execute it:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">describe<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;The send listener&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">var</span> onSendListener<span style="color: #339933;">;</span>
&nbsp;
  beforeEach<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    spyOn<span style="color: #009900;">&#40;</span> rap<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;on&quot;</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">andCallFake</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> event<span style="color: #339933;">,</span> listener <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> event <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;send&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        onSendListener <span style="color: #339933;">=</span> listener<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    createEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  describe<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;of an editor that has not changed&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    it<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;sends nothing&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      spyOn<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">fakeRemoteObject</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;set&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      onSendListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      expect<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">fakeRemoteObject</span>.<span style="color: #000066; font-weight: bold;">set</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span>.<span style="color: #660066;">toHaveBeenCalled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>With the &#8220;beforeEach&#8221; function this does not bloat your code all that much, but it&#8217;s still a couple of lines. So instead I simply made the listener &#8220;public&#8221; (like with the HTML element) and called it <i>after checking it was registered</i>. This is part of the &#8220;contructor&#8221; Suite show above:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">it<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;should add a send listener&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  spyOn<span style="color: #009900;">&#40;</span> rap<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;on&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  createEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  expect<span style="color: #009900;">&#40;</span> rap.<span style="color: #660066;">on</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toHaveBeenCalledWith</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;send&quot;</span><span style="color: #339933;">,</span> editor.<span style="color: #660066;">onSend</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span/></p>
<p>Now I can simply invoke <code>editor.onSend</code> whenever I want, since I now it has been registered with the RAP client, which I trust to work correctly. <b>But</b>, there is one important bit: You should <b>not</b> simply write <code>editor.onSend()</code>, because this would mean that <code>editor</code> will be the context (<code>this</code>) of the invokation. This is not automatically given when working with JavaScript callbacks, and I know it is not the case with <code>rap.on</code>. (To see how I solved that issue for the CKEditor, look at the <code>bindAll</code> function in the <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor/src/resources/handler.js">source code</a>.) Instead, you can write <code>editor.onSend.call();</code>, which executes it without context.</p>
<h3>The Clock makes &#8220;tick&#8221;</h3>
<p>A common issue with JavaScript testing are asynchronously executed function. This custom widget has one of those for setting the editors font, which happens with a small delay using the JavaScript <code>setTimeout</code> function. This means I can not simply call <code>editor.setFont</code> and check the results right away. Jasmine includes two different solutions for this issue. If you want or need your test to emulate the actual runtime scenario, you need to <a href="http://pivotal.github.com/jasmine/#section-Asynchronous_Support">wrap the code</a> of your Spec in <code>runs</code> and <code>waitsFor</code> functions. </p>
<p>Since I use only a mock CKEditor I had no such requirement, and used the alternative: Simply mocking the JavaScript timer.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">describe<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;The setFont function&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">var</span> body<span style="color: #339933;">;</span>
&nbsp;
   beforeEach<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    jasmine.<span style="color: #660066;">Clock</span>.<span style="color: #660066;">useMock</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    createEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    body <span style="color: #339933;">=</span> editor.<span style="color: #660066;">editor</span>.<span style="color: #660066;">document</span>.<span style="color: #660066;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    spyOn<span style="color: #009900;">&#40;</span> body<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;setStyle&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    editor.<span style="color: #660066;">setFont</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;13px Arial&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  it<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;calls body.setStyle on a ready event&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    editor.<span style="color: #660066;">onReady</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    jasmine.<span style="color: #660066;">Clock</span>.<span style="color: #660066;">tick</span><span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    expect<span style="color: #009900;">&#40;</span> body.<span style="color: #660066;">setStyle</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toHaveBeenCalledWith</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;font&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;13px Arial&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Feedback&#8230;</h3>
<p>&#8230;would be welcome, especially if you have trouble writing tests for RAP custom widgets. I did not touch on some topics like sending events to the server (which the CKEditor doesn&#8217;t do), or how to test DOM changes, but that would have completely burst the scope of this article. (<a href="http://eclipsesource.com/blogs/2012/08/14/debugging-javascript-on-android-and-ios/">I sometimes have issus keeping things short&#8230;</a>) Also, on testing the server side: RAP includes a Fixture (not official API) which allows testing the Remote API, but we might change it soon, so I didn&#8217;t want to write about it now. If you are curious, look at <a href="https://github.com/eclipsesource/rap-ckeditor/blob/master/com.eclipsesource.widgets.ckeditor.test/src/com/eclipsesource/widgets/ckeditor/CKEditor_Test.java"><code>CKEditor_Test.java</code></a>.</p>
<h3>Final Words</h3>
<p>Jasmine is awesome. Go use it for something.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Writing+JavaScript+Tests+with+Jasmine+for+RAP&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/&amp;t=Writing+JavaScript+Tests+with+Jasmine+for+RAP" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/#comments">Leave a Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/jasmine/' title='jasmine Tag'>jasmine</a>, <a href='http://eclipsesource.com/blogs/tag/javascript/' title='javascript Tag'>javascript</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/testing/' title='testing Tag'>testing</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a>, <a href='http://eclipsesource.com/blogs/tag/jasmine/' title='jasmine Tag'>jasmine</a>, <a href='http://eclipsesource.com/blogs/tag/javascript/' title='javascript Tag'>javascript</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/testing/' title='testing Tag'>testing</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/04/02/rap-and-jasmine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated Tutorial: Developing Web Application Bundles with RAP and Virgo</title>
		<link>http://eclipsesource.com/blogs/2013/03/18/14961/</link>
		<comments>http://eclipsesource.com/blogs/2013/03/18/14961/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 12:35:27 +0000</pubDate>
		<dc:creator>Florian Waibel</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[virgo]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=14961</guid>
		<description><![CDATA[This is just a heads up for those interested in developing RAP applications with Virgo. I finished updating our tutorial to RAP 2.0 and Virgo 3.6.x (aka Sky). The first part guides you through the setup of your Eclipse IDE and Virgo Jetty Server. The second part is a short walkthrough on how to create <a href="http://eclipsesource.com/blogs/2013/03/18/14961/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This is just a heads up for those interested in developing RAP applications with Virgo. I finished updating our <a href="http://eclipsesource.com/blogs/tutorials/developing-web-application-bundles-with-rap-and-virgo/" title="Developing Web Application Bundles with RAP and Virgo">tutorial</a> to <a href="http://eclipse.org/rap">RAP</a> 2.0 and <a href="http://eclipse.org/virgo/">Virgo</a> 3.6.x (aka Sky).</p>
<p>The first part guides you through the setup of your Eclipse IDE and Virgo Jetty Server. The second part is a short walkthrough on how to create a Hello World Web Application Bundle (WAB) with RAP.</p>
<p>Feedback welcome.</p>
<p>[1] Developing Web Application Bundles with RAP and Virgo &#8211; <a href="http://eclipsesource.com/blogs/tutorials/developing-web-application-bundles-with-rap-and-virgo/" title="Developing Web Application Bundles with RAP and Virgo">http://eclipsesource.com/blogs/tutorials/developing-web-application-bundles-with-rap-and-virgo/</a><br />
[2] RAP – Enabling modular business apps for desktop, browser and mobile – <a href="http://eclipse.org/rap" title="RAP – Enabling modular business apps for desktop, browser and mobile">http://eclipse.org/rap</a><br />
[3] Virgo from eclipseRT – <a href="http://eclipse.org/virgo/">http://eclipse.org/virgo/</a></p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Updated+Tutorial%3A+Developing+Web+Application+Bundles+with+RAP+and+Virgo&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/03/18/14961/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/03/18/14961/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/03/18/14961/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/03/18/14961/&amp;t=Updated+Tutorial%3A+Developing+Web+Application+Bundles+with+RAP+and+Virgo" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/03/18/14961/#comments">1 Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a>, <a href='http://eclipsesource.com/blogs/tag/virgo/' title='virgo Tag'>virgo</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tutorial/' title='tutorial Tag'>tutorial</a>, <a href='http://eclipsesource.com/blogs/tag/virgo/' title='virgo Tag'>virgo</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/03/18/14961/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Keyboard Controls in RAP: Next Step Mnemonics</title>
		<link>http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/</link>
		<comments>http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 11:20:13 +0000</pubDate>
		<dc:creator>Tim Buschtöns</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Editors choice]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[kepler]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=14913</guid>
		<description><![CDATA[Applications built with RAP are often designed for high productivity: The faster you can control the app, the more work you can get done. In many cases, keyboard controls are significantly faster than mouse controls. Consequentially, RAP has continually improved keyboard controls since it&#8217;s inception. What are Mnemonics? Should you not know, Mnemonics are the <a href="http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Applications built with RAP are often designed for high productivity: The faster you can control the app, the more work you can get done. In many cases, keyboard controls are significantly faster than mouse controls. Consequentially, RAP has <a href="http://eclipse.org/rap/noteworthy/1.2/#Workbench">continually</a> <a href="http://eclipsesource.com/blogs/2011/04/27/key-bindings-in-rap/">improved</a> <a href="http://eclipsesource.com/blogs/2012/03/08/using-key-events-effectively-in-rap/">keyboard</a> <a href="http://eclipsesource.com/blogs/2012/03/23/client-side-input-validation-with-rap-clientscripting/">controls</a> since it&#8217;s inception.</p>
<h3>What are Mnemonics?</h3>
<p>Should you not know, Mnemonics are the characters that get underlined in some widgets (especially the menu bar) if you hold down the ALT key. Mac users may scratch their heads right now, because <a href="https://developer.apple.com/library/mac/documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html#//apple_ref/doc/uid/TP40001909-212166-TPXREF146">those aren&#8217;t supported in OS X</a>. Their exact behavior differs a bit between the other platforms, but as long as you hold ALT and press of the underlined character on your keyboard, the widget gets selected. What I like about that is that, unlike normal shortcuts, you do not need to remember Mnemonics, and they can change all the time depending on what&#8217;s on screen. </p>
<h3>Mnemonics in RAP 2.1M1</h3>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/03/mnemonics.png"><img src="http://eclipsesource.com/blogs/wp-content/uploads/2013/03/mnemonics.png" alt="mnemonics Keyboard Controls in RAP: Next Step Mnemonics " width="429" height="147" class="aligncenter size-full wp-image-14926" title="Keyboard Controls in RAP: Next Step Mnemonics " /></a><br />
As of M2 (or the current <a href="http://eclipse.org/rap/downloads/">nightly build</a>), RAP will support Mnemonics on Menus, Buttons, ToolItems, TabItems, Labels and Groups. (Also CTabItem and CLabel.) To enable them, you first need to set the modifier that makes the Mnemonics visible. While you could use ALT, it&#8217;s strongly discouraged, because that would activate the <em>actual</em> Mnemonics of your browser with unpredictable results. I recommend using CTRL+ALT, and reserve CTRL and CTRL+SHIFT for global shortcuts/Key Bindings. The combo can be set with just one line:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">display.<span style="color: #006633;">setData</span><span style="color: #009900;">&#40;</span> RWT.<span style="color: #006633;">MNEMONIC_ACTIVATOR</span>, <span style="color: #0000ff;">&quot;CTRL+ALT&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now all you need to do is to put a &#8220;&#038;&#8221; before a character in a widgets text, and you already have a working Mnemonic. Example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">tabItem.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Tab Item &amp;1&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Since this is a relatively complex new feature, I would love for developers to grab RAP 2.1M1 when it&#8217;s available next week and try it in their application so that we can get some feedback.</p>
<p>Coming soon: <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=403206">Full Accelerator support</a>.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Keyboard+Controls+in+RAP%3A+Next+Step+Mnemonics&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/&amp;t=Keyboard+Controls+in+RAP%3A+Next+Step+Mnemonics" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/#comments">Leave a Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/api/' title='api Tag'>api</a>, <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/kepler/' title='kepler Tag'>kepler</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a>, <a href='http://eclipsesource.com/blogs/tag/api/' title='api Tag'>api</a>, <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/kepler/' title='kepler Tag'>kepler</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/03/15/rap-mnemonics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meet us at EclipseCon 2013 in Boston</title>
		<link>http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/</link>
		<comments>http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 17:04:01 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[Planet OSGi]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[eclipsecon]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[Tabris]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=14876</guid>
		<description><![CDATA[Only two weeks left until EclipseCon! I&#8217;m sure everyone&#8217;s excited to see the new location, make new and meet old friends. This year we have plenty of talks ranging from runtime over mobile to modeling. Pick your choices! Highly Interactive Mobile Apps with RAP (J. Böhme López, H. Staudacher): Smartphones and Tablets have become ubiquitous. The <a href="http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2013/03/eclipseCon2013.png"><img class="size-full wp-image-14883 alignright" style="padding-left: 10px;" alt="eclipseCon2013 Meet us at EclipseCon 2013 in Boston" src="http://eclipsesource.com/blogs/wp-content/uploads/2013/03/eclipseCon2013.png" width="318" height="91" title="Meet us at EclipseCon 2013 in Boston" /></a>Only two weeks left until <a href="http://www.eclipsecon.org/2013/">EclipseCon</a>! I&#8217;m sure everyone&#8217;s excited to see the new location, make new and meet old friends. This year we have plenty of talks ranging from runtime over mobile to modeling. Pick your choices!</p>
<ul>
<li><strong>Highly Interactive Mobile Apps with RAP</strong> (<a href="http://eclipsesource.com/blogs/author/jordi/">J. Böhme López</a>, <a href="http://eclipsesource.com/blogs/author/hstaudacher/">H. Staudacher</a>): Smartphones and Tablets have become ubiquitous. The competitiveness of the market is a win for consumers but a nightmare for developers. To write an application targeted for multiple devices, developers will be faced with an array of platforms and programming languages. <a href="http://www.eclipsecon.org/2013/sessions/highly-interactive-mobile-apps-rap">Reade more&#8230;</a></li>
<li><strong>Deploy and Manage RAP Applications on Equinox, Jetty, Virgo, Apache Karaf, and Tomcat</strong> (<a href="http://eclipsesource.com/blogs/author/mknauer/">M. Knauer)</a>: You&#8217;ve written a RAP-based application, but now you want to make it available to the public? Deploying and managing <a href="http://eclipse.org/rap/">Eclipse RAP</a> applications is challenging because there are so many options to choose from. <a href="http://www.eclipsecon.org/2013/sessions/deploy-and-manage-rap-applications-equinox-jetty-virgo-apache-karaf-and-tomcat">Read more&#8230;</a></li>
<li>
<p id="page-title"><strong>Eclipse/OSGi Puzzlers &#8211; Traps and Pitfalls</strong> (B. Muskalla from Tasktop, <a href="http://eclipsesource.com/blogs/author/hstaudacher/">H. Staudacher</a>): Every API has its quirks. Based on the popular <a href="http://www.youtube.com/watch?v=wbp-3BJWsU8">&#8216;Java Puzzlers&#8217;</a> talks by Joshua Bloch we will present the first Eclipse/OSGi Puzzles talk. What to expect? Traps and Pitfalls from the Eclipse and OSGi universe for you to participate. Besides the common pitfalls we will dive into well known Eclipse APIs and their quirks. Together we will investigate the ramifications of using these APIs. <a href="http://www.eclipsecon.org/2013/sessions/eclipseosgi-puzzlers-traps-and-pitfalls">Read more&#8230;</a></p>
</li>
<li>
<p id="page-title"><strong>EMF Dos and Don’ts</strong> (<a href="http://eclipsesource.com/blogs/author/mkoegel/">M. Koegel</a>, E. Mueller): EMF is very powerful and most of the time fairly simple to use, but of course there are rocks and shallows: Why are there so many Adapters on my EObjects? After overriding some generated code the XML serialization stopped working? My subpackages are not recognized by framework X? EcoreUtil.delete is dead slow? <a href="http://www.eclipsecon.org/2013/sessions/emf-do%E2%80%99s-and-don%E2%80%99t%E2%80%99s">Read more&#8230;</a></p>
</li>
<li>
<p id="page-title"><strong>What every Eclipse developer should know about EMF</strong> (<a href="http://eclipsesource.com/blogs/author/mkoegel/">M. Koegel</a>, E. Mueller): Many talks about e4, modeling and other topics assume you have used the Eclipse Modeling Framework (EMF) before. But what if you haven’t? What is all this modeling stuff about? What is EMF anyway? And who is this Ed guy? <a href="http://www.eclipsecon.org/2013/sessions/what-every-eclipse-developer-should-know-about-emf">Read more&#8230;</a></p>
</li>
<li>
<p id="page-title"><strong>Fuzzy Testing</strong> (<a href="http://eclipsesource.com/blogs/author/mkoegel/">M. Koegel</a>, E. Mueller): Many of the test cases for an application involve data defined by the data model. To achieve good test coverage it is customary to run the test cases for a variety of different input data sets. This can be achieved by manually specifying different input data. However, this is a complex task and it is easy to miss important input data and thereby miss bugs. <a href="http://www.eclipsecon.org/2013/sessions/fuzzy-testing">Read more&#8230;</a></p>
</li>
<li>
<p id="page-title"><strong>Modeling Symposium</strong> (<a href="http://eclipsesource.com/blogs/author/jhelming/">J. Helming</a>, Ed Merks from Itemis): The modeling community is among the most active and diverse in Eclipse&#8217;s ecosystem. The modeling symposium aims to provide a forum for community members to present a brief overview of their work. We will encourage minutes lightning talks to facilitate a broad range of speakers. The primary goal is to introduce interesting, new technological features. <a href="http://www.eclipsecon.org/2013/sessions/modelling-symposium">Read more&#8230;</a></p>
</li>
<li><strong>What every Eclipse developer should know about Eclipse 4</strong> (e4) (<a href="http://eclipsesource.com/blogs/author/jhelming/">J. Helming</a>, E. Neufeld):  This tutorial will give you a jumpstart into the new concepts of the Eclipse 4 Application Platform. If you have previous experience developing with RCP 3.x, but limited or no experience with e4, this tutorial is designed for you. Based on a sample RCP application, we introduce the most important features of the new platform, such as the Application Model, Dependency Injection and the new Programming Model. <a href="http://www.eclipsecon.org/2013/sessions/what-every-eclipse-developer-should-know-about-eclipse-4-e4">Read more&#8230;</a></li>
</ul>
<p>Quite a few of my EclipseSource colleagues are busy right now preparing talks and demos and we hope to meet you there. If you can&#8217;t make it to a talk don&#8217;t be shy and meet us at the bar (after the talks) <img src='http://eclipsesource.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt="icon wink Meet us at EclipseCon 2013 in Boston" class='wp-smiley' title="Meet us at EclipseCon 2013 in Boston" /> .</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Meet+us+at+EclipseCon+2013+in+Boston&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/&amp;t=Meet+us+at+EclipseCon+2013+in+Boston" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/><a href="http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/#comments">Leave a Comment</a>. Tagged with <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/eclipsecon/' title='eclipsecon Tag'>eclipsecon</a>, <a href='http://eclipsesource.com/blogs/tag/emf/' title='emf Tag'>emf</a>, <a href='http://eclipsesource.com/blogs/tag/modeling/' title='modeling Tag'>modeling</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a>, <a href='http://eclipsesource.com/blogs/tag/eclipse/' title='eclipse Tag'>eclipse</a>, <a href='http://eclipsesource.com/blogs/tag/eclipsecon/' title='eclipsecon Tag'>eclipsecon</a>, <a href='http://eclipsesource.com/blogs/tag/emf/' title='emf Tag'>emf</a>, <a href='http://eclipsesource.com/blogs/tag/modeling/' title='modeling Tag'>modeling</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/tabris/' title='Tabris Tag'>Tabris</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/03/11/meet-us-at-eclipsecon-2013-in-boston/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing RAP Applications</title>
		<link>http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/</link>
		<comments>http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 16:19:45 +0000</pubDate>
		<dc:creator>Johannes Eickhold</dc:creator>
				<category><![CDATA[EclipseSource News]]></category>
		<category><![CDATA[Planet Eclipse]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=14556</guid>
		<description><![CDATA[The latest release of RAP 2.0 is still hot. It also contains some improvements for unit testing as Ralf Sternberg mentioned in one of his blog posts that came along with RAP 2.0. The following post will get you up and running with the first JUnit test in your own RAP project. A user interface written <a href="http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/" style="text-decoration: none;">[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The latest release of <a href="http://eclipse.org/rap/noteworthy/2.0/">RAP 2.0</a> is still hot. It also contains some improvements for unit testing as Ralf Sternberg mentioned in <a href="http://eclipsesource.com/blogs/2013/02/04/rap-2-0-countdown-25/">one of his blog posts</a> that came along with RAP 2.0. The following post will get you up and running with the first JUnit test in your own RAP project.</p>
<p>A user interface written with RAP is executed on the server side. This requires you to abstract from the execution environment in your test code. RAP supports you with a so-called <strong>test fixture</strong> to do so. The <a href="http://git.eclipse.org/c/rap/org.eclipse.rap.git/tree/tests/org.eclipse.rap.rwt.testfixture/src/org/eclipse/rap/rwt/testfixture/Fixture.java">test fixture</a> thus enables your test code to run without any server infrastructure.</p>
<p><strong>Disclaimer:</strong><br />
Although the test fixture comes with the official RAP 2.0 target it is not officially supported API. There is work underway to improve the mechanisms currently provided by the test fixture. This means that the test fixture&#8217;s API will <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=395679">change in the future</a>. Please keep this in mind. Nevertheless this post explains the way in which to write unit test for RAP 2.0.</p>
<h3>Create the UI</h3>
<p>As a simple example the class <code>MyComposite</code> should create a new composite with two buttons on it.<br />
Let&#8217;s take a look at a basic test that ensures your <code>MyComposite</code> is created as expected. </p>



<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyComposite_Test <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> Display display<span style="color: #339933;">;</span>
&nbsp;
  @Before
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    Fixture.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    display <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Display<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  @After
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    Fixture.<span style="color: #006633;">tearDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  @Test
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCompositeHasTwoChildren<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    MyComposite myComposite <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyComposite<span style="color: #009900;">&#40;</span> display <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    assertEquals<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span>, myComposite.<span style="color: #006633;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>




<p>As you can see in the <code>setUp()</code> and <code>tearDown()</code> methods, the Fixture provides a convenient way to prepare the environment so your actual UI manipulation in <code>testCompositeHasTwoChildren()</code> will just work. It&#8217;s as simple as this to write you first test.</p>
<h3>Event Handling</h3>
<p>Next to the creation of your UI you most probably want to test that your event handling does the right thing. In RAP, event handling happens in a special phase. The test fixture allows you to set the phase so your test can correctly trigger events. Let&#8217;s assume you registered a <code>ModifyListener</code> on a <code>Text</code> widget. Now your test could ensure the correct listener is invoked and behaves as expected by writing a test like this:</p>



<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// setUp and tearDown as in example above</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testModifyingTextShouldTriggerXY<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Fixture.<span style="color: #006633;">fakePhase</span><span style="color: #009900;">&#40;</span>PhaseId.<span style="color: #006633;">PROCESS_ACTION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// prepare Text widget</span>
&nbsp;
  text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// triggers event</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// assert ModifyListener did the right thing</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>




<h3>Conclusion</h3>
<p>Writing unit tests for your RAP application&#8217;s UI code is easy with help of the test fixture. This post explained the fundamental steps to write such tests. If you have any questions regarding unit testing RAP applications or using one of the other features provided by the test fixture, please comment below.</p>
<p><br/><div style="display: inline-block"><a href="https://twitter.com/intent/tweet?source=webclient&amp;text=Unit+Testing+RAP+Applications&amp;via=eclipsesource&amp;url=http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/" target="_blank" title="Share on Twitter" style="margin-right: 5px;"><img title="Twitter" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/twitter.png" alt="Twitter"/></a><a href="https://plus.google.com/share?url=http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/" target="_blank" title="+1" style="margin-right: 5px;"><img title="Google+" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/google_plus.png" alt="Google+"/></a><a href="http://www.linkedin.com/cws/share?url=http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/" target="_blank" title="Share on LinkedIn" style="margin-right: 5px;"><img title="LinkedIn" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/linkedin.png" alt="LinkedIn"/></a><a href="https://www.facebook.com/sharer/sharer.php?u=http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/&amp;t=Unit+Testing+RAP+Applications" target="_blank" title="Facebook" style="margin-right: 5px;"><img title="Facebook" src="http://eclipsesource.com/blogs/wp-content/plugins/custom-about-author/images/social_media/facebook.png" alt="Facebook"/></a></div><br/>Comments are off for this post.. Tagged with <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/testing/' title='testing Tag'>testing</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a>, <a href='http://eclipsesource.com/blogs/tag/rap/' title='rap Tag'>rap</a>, <a href='http://eclipsesource.com/blogs/tag/testing/' title='testing Tag'>testing</a>, <a href='http://eclipsesource.com/blogs/tag/tips/' title='tips Tag'>tips</a></p>]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2013/02/22/unit-testing-rap-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
