7.22.2011

SmartGWT getting started tutorial | My perception, visions and notions.....

SmartGWT – A getting started guide

If you are familiar with some very good looking and very nice frameworks built on GWT, then probably you have already seen SmartGWT. It’s a beautiful and very useful framework.

If you are not familiar with it, you can read about it from here and you can watch the showcase.

SmartGWT 1.2 is now compatible with GWT 1.6 and GWT 1.7 .

Now, we’ll see how to use smartGWT in your GWT project, in a step by step approach.

  • First, download the smartGWT library from here. Unzip it.
  • Create a GWT project named “TestSmartGwt”. You can follow my tutorial.
  • Add the “smartgwt.jar” (form the unzipped folder) to your project libraries (Project –> Properties –> Java Build Path).

add jar

  • Add “<inherits name="com.smartgwt.SmartGwt"/>” to the module xml file (testsmartgwt.gwt.xml).

gwt xml

  • Add “<script> var isomorphicDir = "testsmartgwt/sc/"; script>” in your host HTML file (inside the war).

html

script

  • Now open the main java file in your client package.

client

  • Remove the default generated code and add the following line of codes to it:

01.package org.hillol.smartclient.client;
02.import com.google.gwt.core.client.EntryPoint;
03.import com.smartgwt.client.util.SC;
04.import com.smartgwt.client.widgets.IButton;
05.import com.smartgwt.client.widgets.events.ClickEvent;
06.import com.smartgwt.client.widgets.events.ClickHandler;
07.
08.public class TestSmartGwt implements EntryPoint
09.{
10.public void onModuleLoad()
11.{
12.IButton button = new IButton("Hello World");
13.button.addClickHandler(new ClickHandler()
14.{
15.public void onClick(ClickEvent event)
16.{
17.SC.say("Hello World from SmartGWT");
18.}
19.});
20.button.draw();
21.}
22.}

  • Now, run the project and you’ll see a button on the hosted page. If you click the button, a dialog box will be shown.

run

That’s all for the 1st tutorial of SmartGWT.



No comments: