Creating a blank project

If you use Eclipse, the easiest way to create a new slim3 project is to use the Slim3 Plugin for Eclipse. If you want to create a new slim3 project manually, see Getting a blank project.

1.Create a new slim3 project

In the File menu, select New > Project... > Slim3 > Slim3 Project.

2.Define your project name as tutorial(your favorite name)

3.Define your root package as tutorial(your favorite name)

The root package will be defined in war/WEB-INF/web.xml as follows:

<context-param>
<param-name>slim3.rootPackage</param-name>
    <param-value>tutorial</param-value>
</context-param>

4.Set Eclipse for testing

In the Window menu, select Preferences > Java > Code Style > Organize Imports. Set 1 to" Number of static imports needed for .*".


In the Window menu, select Preferences > Java > Editor > Content Assist > Favorites. Click the "New Type" button and add org.hamcrest.CoreMatchers, org.junit.Assert, org.junit.matchers.JUnitMatchers.



In the Window menu, select Preferences > General > Workspace. Click the "Refresh automatically" checkbox.


5.Set Eclipse for GWT

In the Project Properties menu, select Google > Web Toolkit Settings. Click the "Use Google Web Toolkit" checkbox.

6.Uncomment out GWTServiceServlet and the servlet-mapping in war/WEB-INF/web.xml
<servlet>
<servlet-name>GWTServiceServlet</servlet-name>
<servlet-class>org.slim3.gwt.server.rpc.GWTServiceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>GWTServiceServlet</servlet-name>
<url-pattern>*.s3gwt</url-pattern>
</servlet-mapping>

7.Create a module

In the File menu, select New > Module.
Input "tutorial" in the "Package" text field.
Input "Main", in the "Module name" text field.
Click the "Finish" button.
"src/tutorial/Main.gwt.xml" will be created as follows:

Main.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.3//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.0.3/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name="com.google.gwt.user.User" />
    <source path="client"/>
</module>


8.Edit Main.gwt.xml ant save it

Edit Main.gwt.xml as follows:

Main.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.0//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.0.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='main'>
    <inherits name="com.google.gwt.user.User" />
    <inherits name='org.slim3.gwt.emul.S3Emulation' />

    <source path="client" />
    <source path="shared" />
</module>

9.Create an Entry Point Class

In the File menu, select New > Entry Point Class.
Input "tutorial.client" in the "Package" text field.
Input "MainEntryPoint" in the "Name" text field.
Click the "Finish" button.
"src/tutorial.client/MainEntryPoint.java" will be created.

10.Create a HTML Page

In the File menu, select New > HTML Page
Input "index.html" in the "File name" text field.
Click the "Finish" button.
"war/index.html" will be created as follows:

index.html

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>index</title>
    <script type="text/javascript" language="javascript"
      src="main/main.nocache.js"></script>
  </head>

  <body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
      style="position:absolute;width:0;height:0;border:0"></iframe>

  </body>
</html>


11.Running the Project

The App Engine SDK includes a web server application you can use to test your application. The server simulates the App Engine environment and services, including sandbox restrictions, the datastore, and the services.

You can start the development server within the Eclipse debugger. In the Run menu, select Debug As > Web Application. See Using the Google Plugin for Eclipse for details on creating the debug configuration.

Slim3 supports HOT reloading, so you can continue to develop this tutorial without restarting your application.

Next...

Continue to Creating a user interface.
Comments