Getting a blank project

Slim3 provides a Slim3 blank project, the easiest way to develop Slim3 application is to use it.

1.Download the latest version of Slim3 blank project(slim3-blank-xxx.zip) and unzip it

2.Import the slim3-blank project into eclipse workspace

3.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.


4.Set Eclipse for GWT

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

5.Rename(Refactor > Rename) the project to tutorial(your favorite name)

6.Define slim3.rootPackage in war/WEB-INF/web.xml as tutorial(your favorite name):
<context-param>
<param-name>slim3.rootPackage</param-name>
    <param-value>tutorial</param-value>
</context-param>

7.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>
8.Enable annotation processing

In the Project Properties menu, select Java Compiler > Annotation Processing > Enable annotation processing, and input "src" in the "Generated source directory".


9.Add slim3-gen-xxx.jar in lib to the annotation processing factory path


In the Project Properties menu, select Java Compiler > Annotation Processing > Factory Path.



Add slim3-gen-xxx.jar to the path.


10.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>


11.Edit Main.gwt.xml

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>

12.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.

13.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>


14.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