Skip to main content
Jump to: navigation, search

Difference between revisions of "RAP/FAQ"

(How do I develop an RWT standalone application with RAP >= 1.5)
(How do I develop an RWT standalone application with RAP >= 1.5)
Line 1,295: Line 1,295:
* Again you can use the RAP Tooling to launch the application from the just created <code>web.xml</code>. Create a new ''RWT Launch Configuration'' and select '''Run from web.xml'''. Enter the location of the web.xml file and specify "rap" as the servlet path.
You may also find the [ JFace] components useful. In order to use them from RWT standalone, you will need to add the following jars from the [ RAP Runtime]:
You may also find the [ JFace] components useful. In order to use them from RWT standalone, you will need to add the following jars from the [ RAP Runtime]:

Revision as of 09:33, 15 November 2011

| RAP wiki home | RAP project home |

This FAQ is still developing. Please also scan the RAP newsgroup archives for answers.


Getting Started

I found a bug in RAP. Where should I report it?

The best way to report a problem or request a new feature in RAP is to use the Bugzilla system. Please follow the instructions in RAP Bug Reporting Howto when submitting a bug report. More details are provided on the RAP Project Bugs page.

Writing RAP Applications

How to create a fullscreen application

  • use the style-bit SWT.NO_TRIM before creating the Shell. This will remove the title-bar, the minimize/maximize/close buttons and the ability for manually resizing the window.
  • overwrite the WorkbenchWindowAdvisor.postWindowCreate() method. Here we set the state of the Shell to maximized.
  • optional: depending on the requirements and complexity of our application it may be desirable to hide the menu bar by calling getWindowConfigurer().setShowMenuBar( false ). This is usually a good choice for small applications where the menu bar may not be needed.
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
  // ...
 public void preWindowOpen() {
   // ...
   getWindowConfigurer().setShellStyle( SWT.NO_TRIM );
   getWindowConfigurer().setShowMenuBar( false );
 public void postWindowCreate() {
   Shell shell = getWindowConfigurer().getWindow().getShell();
   shell.setMaximized( true );
Take a look here for a more detailed discussion of the topic.

How do I add an applet / flash / an existing Javascript libary

  • A very simplistic approach is to create a html page (or a servlet) containing your applet / flash / JS. You can simply use the browser widget to load that page within your application.
  • A tighter integration can be achieved by developing a custom widget as explained here (integrating GMap): custom widget tutorial

How to access the request parameters?

Let's suppose that the request URI looks like the following:

To snippet below will retrieve the values of request parameters var1 and var2.

   HttpServletRequest request = RWT.getRequest();
   String var1 = request.getParameter( "var1" );
   String var2 = request.getParameter( "var2" );

How to access the HTTP session / session store?

In RAP, the sessoin store is the preferred way to store information in the session context. However it also provides access to the HTTP session (see the code below). For working with session singletons, please use the SessionSingletonBase class.

Access the HTTP session / session store from the UI thread: HttpSession session = RWT.getSessionStore().getHttpSession();

Access the HTTP session / session store from a background thread:
final Display display = new Display();
final Runnable bgRunnable = new Runnable() {
  public void run() {
    UICallBack.runNonUIThreadWithFakeContext( display, new Runnable() {
      public void run() {
        Object someValue = RWT.getSessionStore().getAttribute( "myAtt" );
        System.out.println( someValue );
        // access the HTTP session
    } );
Shell shell = new Shell( display );
Button button = new Button( shell, SWT.PUSH );
button.setText( "Start Background Thread" );
button.addSelectionListener( new SelectionAdapter() {
  public void widgetSelected( final SelectionEvent evt ) {
    RWT.getSessionStore().setAttribute( "myAtt", "someValue" );
    Thread thread = new Thread( bgRunnable );
    thread.setDaemon( true );
} );

No context available outside of the request service lifecycle

Why am I getting the exception java.lang.IllegalStateException: No context available outside of the request service lifecycle.?

Your code tries to access session-information but isn't run from the UI thread (the only thread that has a session context associated by default).

The soltion is to wrap your code in a Runnable and have it executed by UICallBack#runNonUIThreadWithFakeContext().

Please also see this thread: [1]

How to integrate the Eclipse Help System in a RAP application?

Applies to RAP 1.1 and 1.2

An example of how to integrate the Eclipse Help webapplication into a RAP application is provided here

After importing the example project, the following plugins have to be added, since they are not included in the RAP target:

  • javax.servlet.jsp
  • org.apache.commons.el
  • org.apache.commons.logging
  • org.apache.jasper
  • org.apache.lucene.analysis
  • org.apache.lucene
  • org.eclipse.equinox.jsp.jasper.registry
  • org.eclipse.equinox.jsp.jasper

The plug-ins mentioned above should be taken from a "suitable" Eclipse installation. Currently (RAP 1.2) this is version 3.4.

Please note that the included launch configuration must be used. It contains the VM argument. Furthermore, the launch config assumes that the "RAP plug-ins" (...workbench etc.) are in your workspace. The target only contains the "Base plug-ins" (...equinox, ..core.runtime). In case your setup differs, you will need to adjust it.

Applies to RAP 1.3

As RAP 1.3 (starting from M2) delivers the infrastructure for the Help system, some of the facts above need to be adjusted. RAP itself only provides the core infrastructure for (like but without the concrete implementation. This means you still need the plug-ins mentioned above (except In case you don't need a sophisticed help solution (no dynamic help, no interaction with cheatsheets, no context help) the solution above is still sufficient. If you need better help integration (which is normally handled by you need to provide your own help ui contributions. This can be achieved by extending the org.eclipse.ui.helpSupport extension point.

An example of contributing a new helpSupport extension can be found in in this project:

The help system customization

The help system customization (like help window title or home page) in a RAP application is simply done by using the org.eclipse.core.runtime.products extension. Even if this extension is not fully supported by RAP, it is necessary to customize the help system. So:

1) add the following in the plugin.xml:

      description="Integration With Eclipse Help System"

2) create the product_customization.ini file in the root folder of my.plugin and add the needed configuration as specified by the product customization guide. For example it could contain:

# Toc ordering.  Ordered list of help TOC's (books) as they would appear
# on the bookshelf. All the other TOCS will be following these books.\
# help system home page

3) add the following VM argument to the launch configuration:


Building and deploying as web application

In order to make the help system available when building and deploying the RAP application as a web application, the following setting must be added to the WEB-INF/web.xml:


(analogue to setting the in the launch configuration)

In order to add the help system customization when building and deploying the RAP application as a web application, the following setting must be added to the config.ini: eclipse.product=my.plugin.help_id (analogue to the -Declipse.product=my.plugin.help_id in the launch configuration.

How to integrate BIRT?

Please read Integrating BIRT into RAP applications to get started.

How to use expression-based activities for role-based access control?

The expression-based activities can be used to restrict the access to UI elements based on user roles. The following example defines an action

  <extension point="org.eclipse.ui.actionSets">
    <actionSet id="demo.actionSet1" label="Admin tools" visible="true">
      <menu id="demo.AdminMenu" label="Admin Menu" path="additions">
        <groupMarker name="groupMarker1"/>
      <action class="demo.Action1" id=""
        label="Action 1" menubarPath="demo.AdminMenu/groupMarker1"

Let's suppose that this action should be available only to users with role admin. We will create an expression-based activity demo.Activity1, which will be enabled when the variable demo.roles contains the string admin. Trough the associated pattern binding, the activity will control the availability of the action and the corresponding menu item.

  <extension point="org.eclipse.ui.activities">
    <activity id="demo.Activity1" name="Admin menu access control">
        <with variable="demo.roles">
          <iterate ifEmpty="true" operator="or">
            <equals value="admin">
    <activityPatternBinding activityId="demo.Activity1"
  <extension point="">
    <sourceProvider provider="demo.AuthenticationProvider">
      <variable name="demo.roles" priorityLevel="workbench">

The value of the demo.roles variable is provided by a subclass of AbstractS