This section explains about the basic steps for setting up GWT environment in eclipse.
- GWT requires JDK 1.6 or higher so the very first requirement is to have JDK installed in your machine.
- Install GWT SDK and plugin for eclipse. you can download the plugins from GWT plugins for eclipse. After successful setup your eclipse will display a google icon as shown below
In this section we will know about the basics of a GWT application. A GWT application consists of four parts
- Module descriptors
- public resources
- client-side code
- server-side code
Module Descriptors
A module descriptor is the configuration file in the form of XML which is used to configure a GWT application. A module descriptor file extension is *.gwt.xml, where * is the name of the application and this file should reside in the project's root.
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='mygwttry'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='com.example.myproj.client.MyGwtTry'/>
<!-- specify the paths for static files like html ,css etc. -->
<public path='...'/>
<public path='...'/>
<!-- specify the paths for external javascript files -->
<script src="js-url"/>
<script src="js-url"/>
<!-- specify the paths for external style sheet files -->
<stylesheet src="css-url"/>
<stylesheet src="css-url"/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
<module rename-to='mygwttry'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='com.example.myproj.client.MyGwtTry'/>
<!-- specify the paths for static files like html ,css etc. -->
<public path='...'/>
<public path='...'/>
<!-- specify the paths for external javascript files -->
<script src="js-url"/>
<script src="js-url"/>
<!-- specify the paths for external style sheet files -->
<stylesheet src="css-url"/>
<stylesheet src="css-url"/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
Public resources
These are all files referenced by your GWT module, such as Host HTML page, CSS or images. The location of these resources can be configured using <public path="path" /> element in module configuration file.
Client-side code
This is the actual Java code written implementing the business logic of the application .The GWT compiler translates into JavaScript, which will eventually run inside the browser. The location of these resources can be configured using <source path="path" /> element in module configuration file.
For example Entry Point code will be used as client side code and its location will be specified using <entry-point class='com.example.myproj.client.MyGwtTry'/>
When a module is loaded, every entry point class is instantiated and its EntryPoint.onModuleLoad() method gets called.
- import com.google.gwt.core.client.EntryPoint;
- public class MyGwtTry implements EntryPoint {
- public void onModuleLoad() {
- private final MyServiceProgAsync myasyn=GWT.create(MyServiceProg.class);
- RootPanel.get().add(vertWid());
- }
- }
Server-side code
This is the server side part of your application and its very much optional. If you are not doing any backend processing with-in your application then you do not need this part, but if there is some processing required at backend and your client-side application interact with the server then you will have to develop these components.
No comments:
Post a Comment