My first steps with Eclipse RAP [step1]
In [step0] I have introduced Eclipse RAP and explained why we have chosen Eclipse RAP for XDocReport. In this step, we will generate a RAP Hello World by using Eclipse PDE Wizard « RAP Hello World ». At the end of this article we will be able to launch this WEB Application :
The goal of this article is to explain how to :
- generate « RAP Hello World » application with « RAP Hello World » PDE Wizard.
- Install RAP Target Platform.
- start the WEB RAP Application.
Generated code, RAP Target Platform… will be explained in the next articles.
You can download rap_step1.zip which contains the following explained projects :
- org.akrogen.dynaresume.raphelloworld which is the generated Eclipse « RAP Hello World » explained in this article.
To use this project you must unzip it and copy/paste in your Eclipse workspace. Import the Eclipse Plugin Project org.akrogen.dynaresume.raphelloworld with File/Import … menu. Go at General/Existing Projects Into Workspace and select org.akrogen.dynaresume.raphelloworld. This action will import the project in your workspace. It requires to install RAP Target Platform to avoid compilation problems.
Download Eclipse RCP/RAP
Before starting read those articles, you must download Eclipse. To develop Eclipse RAP application, I suggest you to download Eclipse for RCP and RAP Developers, distribution :
When you have downloaded it, open your eclipse to start generate our first Eclipse RAP application.
Eclipse Helios is the actual version (may 2011) and provides Eclipse RAP 1.3. But in June 2011, Eclipse Indigo will be available and will provide RAP 1.4. If you want play with RAP 1.4 now, you can download RAP 14 Runtime/Tooling.
RAP Hello World
In this section we will generate a basic RAP application with the PDE template RAP Hello World with RAP 1.3. Before developing RAP Application you must install RAP Target Platform. But at this step we will not do that to see compilation problems when RAP application will be generated.
For RAP 1.4 (Tooling) you will not have this problem. When you chose one of the RAP templates in the New Plug-in Project wizard, the tooling will ensure that a RAP target platform is activated. If not, a dialog will appear that offers to install and activate a RAP target. :
Generate RAP Hello World
RAP application is an Eclipse Plugin. To create a RAP Application we need to create Eclipse Plugin. To do that, go to the File/New/Other… menu :
Select Plug-in Development/Plug-in Project node :
Click on Next button, the wizard page which gives the choice to create OSGi Bundle or Eclipse Plugin is displayed :
- fill Project name field with org.akrogen.dynaresume.raphelloworld.
- select the radio button Eclipse version because we would like to develop RAP application which is an Eclipse Plugin.
Click on Next button, the wizard page which configure the Eclipse Plugin is displayed :
- ID field is the Bundle identifier (Bundle-SymbolicName: org.akrogen.dynaresume.raphelloworld).
- Version field is the Bundle version (Bundle-Version: 1.0.0.qualifier).
- Name field is the Bundle name (Bundle-Name: RAP Hello World).
- Execution Environment set the minimal version of the JRE in order to execute the bundle (Bundle-RequiredExecutionEnvironment: JavaSE-1.6).
- you can unselect generate an activator, a Java class that controls the plug-in’s life cycle to avoid generating a Bundle Activator
- select This plug-in will make contributions to the UI because we want to generate RAP application
- select no for Would you like create a rich client application? because we want generate a RAP application and not RCP application.
Click on Next button, the wizard page which show several PDE templates is displayed :
Select RAP Hello World template to generate RAP application, Hello World. When you select this template, you can notice on the right view a description of this PDE template « This code will need the RAP target to compile. At this step RAP target is not installed and we will see compilation problems when project will be generated.
Click on Next button, the wizard page which give you the capability to customize package names, class names of the RAP project to generate is displayed :
Don’t change default values and click on Finish Button to generate the RAP application. When generation is done, your workspace looks like this :
New Eclipse Plugin project org.akrogen.dynaresume.raphelloworld is added to your workspace :
You can notice that there are compilation problems (see generated Java classes). If you open MANIFEST.MF you will see the main problem :
This error means that the Eclipse Plugin org.eclipse.rap.ui cannot be found in the current Target Platform.
RCP Target Platform
RAP compilation problems come from the current Target Platform which is not configured for RAP. To resolve compilation problems we need configure Target Platform for RAP. Before doing that, we can edit the current Target Platform used. Go to the menu Window/Preferences :
Select Plug-in Development/Target Platform node to see the (only) current Target Platform configured :
Target Platform configure the whole Plugins that you can use in your Eclipse Workspace. It is also used to know which Plugins must be started when the application is started. To see plugins which compose Target Platform, click on Edit button. The « Edit Target Definition » dialog display :
The Locations tab display the folders (by default your ECLIPSE_HOME/plugins) which contains plugins. To see plugins coming from folders declared in the Locations tab, go to the Content tab :
You can notice that org.eclipse.rap.ui plugin is missing, so there is compilation problem.
Install RAP Target Platform
In this section we will install RAP Target Platform which will contain for instance org.eclipse.rap.ui plugins. To do that go to Help/Welcome :
This menu opens the Welcome view :
Click on Overview icon to open the Overview section :
Click on Rich Ajax Platform (RAP) icon to open the Rich Ajax Platform (RAP) section :
Click on Install Target Platform icon to install RAP Target Platform to open Target Platform Installation dialog :
Click on OK button to install RAP Target Platform. When RAP Target Platform is installed, your workspace will be recompiled (automaticly) with no errors :
RAP Target Platform
Now we can start to generate RAP application but before doing that, we can edit the RAP Target Platform which was installed. Go to the menu Window/Preferences and select Plug-in Development/Target Platform node. You will see that there are 2 Target Platform. The Rich Ajax Platform (1.3) is active : :
Click on Edit button to open the « Edit Target Definition » dialog :
You can see the folder which contains (RAP and another) plugins. If you click on Content tab, you will see the plugins :
You can check that org.eclipse.rap.ui exists (it explains that we have no compilation problem).
Launch RAP Hello World
In this section we can start to generate RAP Application. To do that open MANIFEST.MF and click on Overview tab.
Click on Launch a RAP Application link on Testing section. This action start the RAP WEB application by starting Jetty server and open Browser view with the first home page of the WEB Application :
Fix Jetty Port
In this screen, RAP application is available with the URL :
http://127.0.0.1:2358/rap?startup=hello but each time you will restart your RAP application, port will change (ex : http://127.0.0.1:3342/rap?startup=hello). To fix a port go to the Run/Run Configurations… menu :
Select the RAP Application launch, go to the Main tab and fix the port value to 8080 in the Runtime Settings/Manual Port configuration :
Now your RAP application will be available every time with the URL http://127.0.0.1:8080/rap?startup=hello. Next articles will use this URL.
In this article, we have installed RAP Target Platform, generate our first RAP Application, and started it. PDE Tooling is a great help to start quickly a RAP Application. Before explaining generated code of « RAP Hello World » Application and RAP Architecture, you need understand OSGi. I will explain in the [step2] what is an OSGi bundle with PDE.