Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "RAP/FAQ"

< RAP
Line 76: Line 76:
 
* Create a new Java project.
 
* Create a new Java project.
 
* In the project create the folders:
 
* In the project create the folders:
** "web"
+
** "WEB-INF"
** "web\WEB-INF"
+
** "WEB-INF\lib"
** "web\WEB-INF\lib"
+
** "WEB-INF\classes"
** "web\WEB-INF\classes"
+
** "WEB-INF\conf"     
** "web\WEB-INF\conf"     
+
* In "WEB-INF" create a file "web.xml":  
* In "web\WEB-INF" create a file "web.xml":  
+
 
<pre>
 
<pre>
    <?xml version="1.0" encoding="ISO-8859-1"?>
+
<?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
            version="2.4">
+
  version="2.4">
   
+
 
            <display-name>Welcome to Tomcat</display-name>
+
  <display-name>Welcome to Tomcat</display-name>
            <description>Welcome to Tomcat</description>
+
  <description>Welcome to Tomcat</description>
   
+
 
            <context-param>
+
  <context-param>
                    <param-name>org.eclipse.rwt.entryPoints</param-name>
+
    <param-name>org.eclipse.rwt.entryPoints</param-name>
                    <param-value>org.eclipse.rap.helloworld.HelloWorld</param-value>
+
    <param-value>org.eclipse.rap.helloworld.HelloWorld</param-value>
            </context-param>
+
  </context-param>
   
+
 
            <listener>
+
  <listener>
                    <listener-class>
+
    <listener-class>
                            org.eclipse.rwt.internal.engine.RWTServletContextListener
+
      org.eclipse.rwt.internal.engine.RWTServletContextListener
                    </listener-class>
+
    </listener-class>
            </listener>
+
  </listener>
   
+
 
            <servlet>
+
  <servlet>
                    <servlet-name>rapServlet</servlet-name>
+
    <servlet-name>rapServlet</servlet-name>
                    <servlet-class>
+
    <servlet-class>
                            org.eclipse.rwt.internal.engine.RWTDelegate
+
      org.eclipse.rwt.internal.engine.RWTDelegate
                    </servlet-class>
+
    </servlet-class>
            </servlet>
+
  </servlet>
   
+
 
            <servlet-mapping>
+
  <servlet-mapping>
                    <servlet-name>rapServlet</servlet-name>
+
    <servlet-name>rapServlet</servlet-name>
                    <url-pattern>/main</url-pattern>
+
    <url-pattern>/main</url-pattern>
            </servlet-mapping>
+
  </servlet-mapping>
    </web-app>  
+
</web-app>  
 
</pre>  
 
</pre>  
 
* You can use different features (branding + theming), that normally are done with extension points by specifying some variables.
 
* You can use different features (branding + theming), that normally are done with extension points by specifying some variables.
 
This is optional:
 
This is optional:
 
<pre>
 
<pre>
    <context-param>
+
<context-param>
            <param-name>org.eclipse.rwt.themes</param-name>
+
  <param-name>org.eclipse.rwt.themes</param-name>
            <param-value>useradmin#theme/theme.properties</param-value>
+
  <param-value>useradmin#theme/theme.properties</param-value>
    </context-param>
+
</context-param>
  
    <context-param>
+
<context-param>
            <param-name>org.eclipse.rwt.brandings</param-name>
+
  <param-name>org.eclipse.rwt.brandings</param-name>
            <param-value>rap.RAPUseradminBranding</param-value>
+
  <param-value>rap.RAPUseradminBranding</param-value>
    </context-param>   
+
</context-param>   
</pre>    
+
</pre>        
* In "web\WEB-INF\conf" create a file "w4t.xml":
+
* In "WEB-INF\conf" create a file "w4t.xml":
 
<pre>
 
<pre>
    <?xml version="1.0" encoding="UTF-8"?>
+
<?xml version="1.0" encoding="UTF-8"?>
    <w4t:application xmlns:w4t="http://w4toolkit.com/"
+
<w4t:application xmlns:w4t="http://w4toolkit.com/"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
+
  xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
            <initialisation>
+
  <initialisation>
                    <lifecycle>
+
    <lifecycle>
                            org.eclipse.rwt.internal.lifecycle.RWTLifeCycle
+
      org.eclipse.rwt.internal.lifecycle.RWTLifeCycle
                    </lifecycle>
+
    </lifecycle>
            </initialisation>
+
  </initialisation>
    </w4t:application>     
+
</w4t:application>     
 
</pre>     
 
</pre>     
* Copy the folloing jars from RAP in "web\WEB-INF\lib":
+
* Copy the folloing jars from RAP in "WEB-INF\lib":
 
** org.eclipse.core.commands
 
** org.eclipse.core.commands
 
** org.eclipse.equinox.common
 
** org.eclipse.equinox.common
Line 148: Line 147:
 
** org.eclipse.rap.rwt     
 
** org.eclipse.rap.rwt     
 
* Add these jars to the project build path as external jars.
 
* Add these jars to the project build path as external jars.
* Change the project output directory to "web\WEB-INF\classes".
+
* Change the project output directory to "WEB-INF\classes".
 
* Use a normal implementation of IEntryPoint.createUI - HelloWorld.java:
 
* Use a normal implementation of IEntryPoint.createUI - HelloWorld.java:
 
<pre>
 
<pre>
    package org.eclipse.rap.helloworld;
+
package org.eclipse.rap.helloworld;
 +
 
 +
import org.eclipse.rwt.lifecycle.IEntryPoint;
 +
import org.eclipse.swt.SWT;
 +
import org.eclipse.swt.layout.GridLayout;
 +
import org.eclipse.swt.widgets.Display;
 +
import org.eclipse.swt.widgets.Label;
 +
import org.eclipse.swt.widgets.Shell;
 +
 
 +
public class HelloWorld implements IEntryPoint {
 +
 
 +
  public int createUI() {     
 +
    Display display = new Display();
 +
    Shell shell = new Shell(display);
 +
    shell.setLayout(new GridLayout());
 +
       
 +
    Label label = new Label ( shell, SWT.NONE );
 +
    label.setText( "Hello RAP World" );
 +
    label.setSize( 80, 20 );
 +
           
 +
    shell.setSize(500, 400);       
 +
    shell.open();
 +
    while (!shell.isDisposed()) {
 +
      if (!display.readAndDispatch())
 +
        display.sleep();
 +
    }
 +
    display.dispose();     
  
import org.eclipse.rwt.lifecycle.IEntryPoint;
+
    return 0;
import org.eclipse.swt.SWT;
+
  }
import org.eclipse.swt.layout.GridLayout;
+
}
import org.eclipse.swt.widgets.Display;
+
import org.eclipse.swt.widgets.Label;
+
import org.eclipse.swt.widgets.Shell;
+
+
public class HelloWorld implements IEntryPoint {
+
+
public int createUI() {
+
Display display = new Display();
+
Shell shell = new Shell(display);
+
shell.setLayout(new GridLayout());
+
+
Label label = new Label ( shell, SWT.NONE );
+
            label.setText( "Hello RAP World" );
+
            label.setSize( 80, 20 );
+
+
shell.setSize(500, 400);
+
shell.open();
+
while (!shell.isDisposed()) {
+
if (!display.readAndDispatch())
+
display.sleep();
+
}
+
display.dispose();
+
+
return 0;
+
}
+
}
+
 
</pre>     
 
</pre>     
* ZIP the content of the "web" directory as "RWT_Standalone.war".
+
* ZIP the the "WEB-INF" directory (including the directory) as "RWT_Standalone.war".
 
* Deploy the "RWT_Standalone.war" in Tomcat.
 
* Deploy the "RWT_Standalone.war" in Tomcat.
 
* Start the standalone RWT application from:
 
* Start the standalone RWT application from:
<pre>http://<host>:<port>/RWT_Standalone/main</pre>
+
<pre>http://<host>:<port>/RWT_Standalone/main</pre>  
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]
 
[[Category:RAP]]
 
[[Category:RAP]]

Revision as of 09:54, 15 April 2008

| RAP wiki home | RAP project home |

This section is intended to host differents Faqs about RAP and RWT. One source could be the newsgroup about RAP itself...


How to hide the window in rap

[| Lien]

Exported .war does not work

My application is working at development time, but when I export it the web application does not work. Check the following:

  • check your build.properties
    • are you exporting the plugin.xml
    • are all libraries you are using in the plugin.jars
    • TIP: As pde build sometimes swallows error messages try exporting your feature with "Deployable feature" export, this may turn up error messages
  • enable the osgi console by adding this init-param to the web.xml:
  <init-param>
     <param-name>commandline</param-name>
     <param-value>-console</param-value>			
  </init-param>
    • you may want to add a port after -console in unix environments, you can then telnet to the osgi console
    • type ss in the console and see if all bundles are started. If not try starting them with "start <bundle-id>"
    • the stack traces may hint to what is missing
  • start with a working example: rapdemo.war and integrate your plugins

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 do I make remote calls to EJB's deployed on Jboss 4.x AS

This is not a solution for calling local interface EJB's (I wasn't able to do it :( ), neither for EJB3 specification (didn't tried yet)

Nevertheless is more useful to make remote calls as the RAP application and the JBoss AS could be on separate machines (or will be sometime in the application life-cycle)

  • prepare a jar with EJB's interfaces which you are about to call from RAP (I think here you may use it wrapped as a bundle if you want to separate it from your application bundle)
  • put the jar in the application runtime classpath or add it as a dependency plugin if you use it as a bundle
  • add the following jar's from the jboss installation folder in the application runtime classpath : jboss.jar, jboss-remoting.jar, jboss-serialization.jar, jbosssx.jar, jboss-transaction.jar, jnpserver.jar

Here's an example code for calling the EJB's remote interface :

Hashtable<String, String> props = new Hashtable<String, String>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099"); //here you put your JBoss AS server's address
Context ctx = null;
try {
	ctx = new InitialContext(props);
} catch (NamingException e) {
	throw new RuntimeException("fail to get initial context", e);
}
Object obj = null;
try {
	obj = ctx.lookup("Test"); //The jndi ejbs name is Test
} catch (NamingException e) {
	throw new RuntimeException("could not obtain test home interface", e);
}
TestHome home = (TestHome) PortableRemoteObject.narrow(obj, TestHome.class);
try {
	testService = home.create();
} catch (CreateException e) {
	throw new RuntimeException("could not create test remote interface", e);			
} catch (RemoteException e) {
	throw new RuntimeException("remote exception when creating test remote interface", e);
}
try {
	testService.callSomeBusinessMethod(...);
} catch (RemoteException e) {
	throw new RuntimeException("remote exception when calling business method", e);
}

How do I use a RWT standalone application in Tomcat

To use the RWT standalone application in Tomcat follow the steps below:

  • Create a new Java project.
  • In the project create the folders:
    • "WEB-INF"
    • "WEB-INF\lib"
    • "WEB-INF\classes"
    • "WEB-INF\conf"
  • In "WEB-INF" create a file "web.xml":
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">

  <display-name>Welcome to Tomcat</display-name>
  <description>Welcome to Tomcat</description>

  <context-param>
    <param-name>org.eclipse.rwt.entryPoints</param-name>
    <param-value>org.eclipse.rap.helloworld.HelloWorld</param-value>
  </context-param>

  <listener>
    <listener-class>
      org.eclipse.rwt.internal.engine.RWTServletContextListener
    </listener-class>
  </listener>

  <servlet>
    <servlet-name>rapServlet</servlet-name>
    <servlet-class>
      org.eclipse.rwt.internal.engine.RWTDelegate
    </servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>rapServlet</servlet-name>
    <url-pattern>/main</url-pattern>
  </servlet-mapping>
</web-app> 
  • You can use different features (branding + theming), that normally are done with extension points by specifying some variables.

This is optional:

<context-param>
  <param-name>org.eclipse.rwt.themes</param-name>
  <param-value>useradmin#theme/theme.properties</param-value>
</context-param>

<context-param>
  <param-name>org.eclipse.rwt.brandings</param-name>
  <param-value>rap.RAPUseradminBranding</param-value>
</context-param>  
  • In "WEB-INF\conf" create a file "w4t.xml":
<?xml version="1.0" encoding="UTF-8"?>
<w4t:application xmlns:w4t="http://w4toolkit.com/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
  <initialisation>
    <lifecycle>
      org.eclipse.rwt.internal.lifecycle.RWTLifeCycle
    </lifecycle>
  </initialisation>
</w4t:application>    
  • Copy the folloing jars from RAP in "WEB-INF\lib":
    • org.eclipse.core.commands
    • org.eclipse.equinox.common
    • org.eclipse.rap.jface
    • org.eclipse.rap.rwt
  • Add these jars to the project build path as external jars.
  • Change the project output directory to "WEB-INF\classes".
  • Use a normal implementation of IEntryPoint.createUI - HelloWorld.java:
package org.eclipse.rap.helloworld;

import org.eclipse.rwt.lifecycle.IEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class HelloWorld implements IEntryPoint {

  public int createUI() {       
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
        
    Label label = new Label ( shell, SWT.NONE );
    label.setText( "Hello RAP World" );
    label.setSize( 80, 20 );
            
    shell.setSize(500, 400);        
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();      

    return 0;
  }
}
  • ZIP the the "WEB-INF" directory (including the directory) as "RWT_Standalone.war".
  • Deploy the "RWT_Standalone.war" in Tomcat.
  • Start the standalone RWT application from:
http://<host>:<port>/RWT_Standalone/main

Back to the top