Free Essay

Gwt Tutorial

In:

Submitted By fener33
Words 14136
Pages 57
Google Web Toolkit Tutorial

GOOGLE WEB TOOLKIT TUTORIAL

Simply Easy Learning by tutorialspoint.com

tutorialspoint.com i COPYRIGHT& DISCLAIMER NOTICE

All

the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com.Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors andtutorialspointprovidesno guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com

ii

ABOUT THE TUTORIAL

GWT Tutorial
Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. GWT is used by many products at Google, including Google AdWords and Orkut. GWT is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0. This tutorial will give you great understanding on GWT concepts needed to get a web application up and running.

Audience
This tutorial is designed for Software Professionals who are willing to learn GWT Programming in simple and easy steps. This tutorial will give you great understanding on GWT Programming concepts and after completing this tutorial you will be at intermediate level of experties from where you can take yourself at higher level of expertise.

Prerequisites
Before proceeding with this tutorial you should have a basic understanding of Java programming language, text editor and execution of programs etc. Because we are going to develop web based applications usin GWT, so it will be good if you have understanding on other web technologies like, HTML, CSS, AJAX etc.

Copyright & Disclaimer Notice
All
the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com

iii

T able of Contents
GWT Tutorial ............................................................................ iii Audience .................................................................................. iii Prerequisites ............................................................................ iii Copyright & Disclaimer Notice .................................................. iii GWTOverview .......................................................................... 1
What is GWT? .............................................................................................. 1 Why to use GWT?......................................................................................... 1 Disadvantages of GWT .............................................................................. 2 The GWT Components .................................................................................. 2

Environment ............................................................................. 3
System Requirement ................................................................................. 3 Step 1 - Verify Java installation on your machine ...................................... 3 Step 2 - Setup Java Development Kit (JDK): ............................................. 4 Step 3 - Setup Eclipse IDE ........................................................................ 4 Step 4: Install GWT SDK & Plugin for Eclipse ........................................... 5 Step 5: Setup Apache Tomcat: .................................................................. 6

Applications .............................................................................. 8
Module Descriptors .................................................................................... 8 Public resources ...................................................................................... 10 Client-side code ....................................................................................... 10 Server-side code...................................................................................... 11

Create Application .................................................................. 12
Step 1 - Create Project .......................................................................... 12 Step 2 - Modify Module Descriptor: HelloWorld.gwt.xml .......................... 15 Step 3 - Modify Style Sheet: HelloWorld.css............................................ 15 Step 4 - Modify Host File: HelloWorld.html .............................................. 16 Step 5 - Modify Entry Point: HelloWorld.java ........................................... 16 Step 6 - Compile Application.................................................................... 16 Step 6 - Run Application .......................................................................... 18

Deploy Application ................................................................. 20
Create WAR File ...................................................................................... 22 Deploy WAR file....................................................................................... 22 iii Run Application........................................................................................ 22

Style with CSS ....................................................................... 24
CSS Styling APIs ..................................................................................... 24 Primary & Secondary Styles .................................................................... 25 Associating CSS Files ............................................................................. 26 GWT CSS Example ................................................................................. 26

Basic Widgets ........................................................................ 30
GWT UI Elements: ................................................................................... 30 GWT UIObject Class ............................................................................... 31 Introduction .............................................................................................. 31 Class declaration ..................................................................................... 31 Field ......................................................................................................... 31 Class constructors ................................................................................... 31 Class methods ......................................................................................... 31 Methods inherited .................................................................................... 33 GWT Widget Class .................................................................................. 34 Introduction .............................................................................................. 34 Class declaration ..................................................................................... 34 Field ......................................................................................................... 34 Class constructors ................................................................................... 34 Class methods ......................................................................................... 34 Methods inherited .................................................................................... 35 Basic Widgets .......................................................................................... 35 Label ........................................................................................................ 36 Introduction .............................................................................................. 36 Class declaration ..................................................................................... 36 CSS style rules ........................................................................................ 36 Class constructors ................................................................................... 36 Class methods ......................................................................................... 36 Methods inherited .................................................................................... 37 Label Widget Example ............................................................................. 37 HTML ....................................................................................................... 40 Introduction .............................................................................................. 40 Class declaration ..................................................................................... 40 CSS style rules ........................................................................................ 40 Class constructors ................................................................................... 40 Class methods ......................................................................................... 41 Methods inherited .................................................................................... 41 Html Widget Example .............................................................................. 41 iii IMAGE ..................................................................................................... 43 Introduction .............................................................................................. 43 Class declaration ..................................................................................... 44 CSS style rules ........................................................................................ 44 Class constructors ................................................................................... 44 Class methods ......................................................................................... 44 Methods inherited .................................................................................... 45 Image Widget Example ............................................................................ 45 ANCHOR ................................................................................................. 47 Introduction .............................................................................................. 47 Class declaration ..................................................................................... 47 CSS style rules ........................................................................................ 48 Class constructors ................................................................................... 48 Class methods ......................................................................................... 48 Methods inherited .................................................................................... 49 Anchor Widget Example .......................................................................... 49

Form Widgets ......................................................................... 52
Form Widgets .......................................................................................... 52 Introduction .............................................................................................. 53 Class declaration ..................................................................................... 53 CSS style rules ........................................................................................ 53 Class constructors ................................................................................... 53 Class methods ......................................................................................... 54 Methods inherited .................................................................................... 54 Button Widget Example ........................................................................... 54 Introduction .............................................................................................. 57 Class declaration ..................................................................................... 57 CSS style rules ........................................................................................ 57 Class constructors ................................................................................... 57 Class methods ......................................................................................... 58 Methods inherited .................................................................................... 58 PushButton Widget Example ................................................................... 59 Introduction .............................................................................................. 62 Class declaration ..................................................................................... 62 CSS style rules ........................................................................................ 62 Class constructors ................................................................................... 62 Class methods ......................................................................................... 63 Methods inherited .................................................................................... 63 ToggleButton Widget Example ................................................................ 63 iii Introduction .............................................................................................. 66 Class declaration ..................................................................................... 66 CSS style rules ........................................................................................ 66 Class constructors ................................................................................... 66 Class methods ......................................................................................... 66 Methods inherited .................................................................................... 67 CheckBox Widget Example ..................................................................... 68 Introduction .............................................................................................. 70 Class declaration ..................................................................................... 70 CSS style rules ........................................................................................ 71 Class constructors ................................................................................... 71 Class methods ......................................................................................... 71 Methods inherited .................................................................................... 71 RadioButton Widget Example .................................................................. 71 Introduction .............................................................................................. 74 Class declaration ..................................................................................... 74 CSS style rules ........................................................................................ 74 Class constructors ................................................................................... 75 Class methods ......................................................................................... 75 Methods inherited .................................................................................... 76 ListBox Widget Example .......................................................................... 76 Introduction .............................................................................................. 79 Class declaration ..................................................................................... 79 CSS style rules ........................................................................................ 80 Class constructors ................................................................................... 80 Class methods ......................................................................................... 80 Methods inherited .................................................................................... 82 Introduction .............................................................................................. 86 Class declaration ..................................................................................... 86 CSS style rules ........................................................................................ 86 Class constructors ................................................................................... 86 Class methods ......................................................................................... 86 Methods inherited .................................................................................... 87 TextBox Widget Example......................................................................... 87 Introduction .............................................................................................. 89 Class declaration ..................................................................................... 89 CSS style rules ........................................................................................ 90 Class constructors ................................................................................... 90 Class methods ......................................................................................... 90 iii Methods inherited .................................................................................... 90 PasswordTextBox Widget Example ......................................................... 90 Introduction .............................................................................................. 93 Class declaration ..................................................................................... 93 CSS style rules ........................................................................................ 93 Class constructors ................................................................................... 93 Class methods ......................................................................................... 93 Methods inherited .................................................................................... 94 TextBox Widget Example......................................................................... 94 Introduction .............................................................................................. 97 Class declaration ..................................................................................... 97 CSS style rules ........................................................................................ 97 Class constructors ................................................................................... 97 Class methods ......................................................................................... 97 Methods inherited .................................................................................... 98 RichTextBox Widget Example ................................................................. 98 Introduction ............................................................................................ 101 Class declaration ................................................................................... 101 CSS style rules ...................................................................................... 101 Class constructors ................................................................................. 101 Class methods ....................................................................................... 101 Methods inherited .................................................................................. 102 FileUpload Widget Example................................................................... 102 Introduction ............................................................................................ 106 Class declaration ................................................................................... 107 Class constructors ................................................................................. 107 Methods inherited .................................................................................. 107 Hidden Widget Example ........................................................................ 108

Complex Widgets ................................................................. 111
Complex Widgets................................................................................... 111 Introduction ............................................................................................ 112 Class declaration ................................................................................... 112 CSS style rules ...................................................................................... 112 Class constructors ................................................................................. 112 Class methods ....................................................................................... 112 Methods inherited .................................................................................. 114 Tree Widget Example ............................................................................ 115 Introduction ............................................................................................ 118 Class declaration ................................................................................... 119 iii CSS style rules ...................................................................................... 119 Class constructors ................................................................................. 119 Class methods ....................................................................................... 120 Methods inherited .................................................................................. 121 MenuBar Widget Example ..................................................................... 122 Introduction ............................................................................................ 127 Class declaration ................................................................................... 127 CSS style rules ...................................................................................... 128 Class constructors ................................................................................. 128 Class methods ....................................................................................... 128 Methods inherited .................................................................................. 130 DatePicker Widget Example .................................................................. 130 Introduction ............................................................................................ 135 Class declaration ................................................................................... 135 Class constructors ................................................................................. 136 Class methods ....................................................................................... 136 Methods inherited .................................................................................. 137 CellTree Widget Example ...................................................................... 137 Introduction ............................................................................................ 144 Class declaration ................................................................................... 144 Class constructors ................................................................................. 144 Class methods ....................................................................................... 144 Methods inherited .................................................................................. 145 CellList Widget Example ........................................................................ 145 Introduction ............................................................................................ 149 Class declaration ................................................................................... 149 Class constructors ................................................................................. 149 Class methods ....................................................................................... 150 Methods inherited .................................................................................. 151 CellTable Widget Example .................................................................... 151 Introduction ............................................................................................ 155 Class declaration ................................................................................... 155 Class constructors ................................................................................. 156 Class methods ....................................................................................... 156 Methods inherited .................................................................................. 156 CellBrowser Widget Example ................................................................ 157

Layout Panels ...................................................................... 164
Introduction ............................................................................................ 164 Class declaration ................................................................................... 164 iii Field ....................................................................................................... 165 Class constructors ................................................................................. 165 Class methods ....................................................................................... 165 Methods inherited .................................................................................. 165 Layout Panels ........................................................................................ 166 Introduction ............................................................................................ 167 Class declaration ................................................................................... 167 Class constructors ................................................................................. 167 Class methods ....................................................................................... 167 Methods inherited .................................................................................. 168 FlowPanel Widget Example ................................................................... 168 Introduction ............................................................................................ 170 Class declaration ................................................................................... 170 Class constructors ................................................................................. 171 Class methods ....................................................................................... 171 Methods inherited .................................................................................. 171 HorizontalPanel Widget Example .......................................................... 172 Introduction ............................................................................................ 174 Class declaration ................................................................................... 174 Class constructors ................................................................................. 174 Class methods ....................................................................................... 174 Methods inherited .................................................................................. 175 VerticalPanel Widget Example............................................................... 175 Introduction ............................................................................................ 178 Class declaration ................................................................................... 178 CSS style rules ...................................................................................... 178 Class constructors ................................................................................. 178 Class methods ....................................................................................... 178 Methods inherited .................................................................................. 179 HorizontalSplitPanel Widget Example ................................................... 180 Introduction ............................................................................................ 182 Class declaration ................................................................................... 182 CSS style rules ...................................................................................... 183 Class constructors ................................................................................. 183 Class methods ....................................................................................... 183 Methods inherited .................................................................................. 184 VerticalSplitPanel Widget Example........................................................ 184 Introduction ............................................................................................ 187 Class declaration ................................................................................... 187 iii Class constructors ................................................................................. 187 Class methods ....................................................................................... 187 Methods inherited .................................................................................. 188 FlexTable Widget Example .................................................................... 188 Introduction ............................................................................................ 192 Class declaration ................................................................................... 192 Class constructors ................................................................................. 192 Class methods ....................................................................................... 192 Methods inherited .................................................................................. 193 Grid Widget Example ............................................................................. 193 Introduction ............................................................................................ 195 Class declaration ................................................................................... 195 Class constructors ................................................................................. 195 Class methods ....................................................................................... 195 Methods inherited .................................................................................. 196 DeckPanel Widget Example .................................................................. 196 Introduction ............................................................................................ 199 Class declaration ................................................................................... 199 Class constructors ................................................................................. 200 Class methods ....................................................................................... 200 Methods inherited .................................................................................. 200 DockPanel Widget Example .................................................................. 201 Introduction ............................................................................................ 203 Class declaration ................................................................................... 204 Class constructors ................................................................................. 204 Class methods ....................................................................................... 204 Methods inherited .................................................................................. 204 HTMLPanel Widget Example ................................................................. 205 Introduction ............................................................................................ 207 Class declaration ................................................................................... 207 Class constructors ................................................................................. 208 Class methods ....................................................................................... 208 Methods inherited .................................................................................. 210 TabPanel Widget Example .................................................................... 210 Introduction ............................................................................................ 213 Class declaration ................................................................................... 213 Class constructors ................................................................................. 213 Class methods ....................................................................................... 213 Methods inherited .................................................................................. 213 iii Composite Widget Example................................................................... 214 Introduction ............................................................................................ 216 Class declaration ................................................................................... 216 Class constructors ................................................................................. 217 Class methods ....................................................................................... 217 Methods inherited .................................................................................. 217 SimplePanel Widget Example................................................................ 217 Introduction ............................................................................................ 220 Class declaration ................................................................................... 220 Class constructors ................................................................................. 221 Class methods ....................................................................................... 221 Methods inherited .................................................................................. 222 ScrollPanel Widget Example.................................................................. 222 Introduction ............................................................................................ 224 Class declaration ................................................................................... 224 Class constructors ................................................................................. 225 Class methods ....................................................................................... 225 Methods inherited .................................................................................. 227 FocusPanel Widget Example ................................................................. 227 Introduction ............................................................................................ 229 Class declaration ................................................................................... 229 Class constructors ................................................................................. 229 Class methods ....................................................................................... 230 Methods inherited .................................................................................. 231 FormPanel Widget Example .................................................................. 231 Introduction ............................................................................................ 235 Class declaration ................................................................................... 235 Class constructors ................................................................................. 235 Class methods ....................................................................................... 235 Methods inherited .................................................................................. 238 PopupPanel Widget Example ................................................................ 238 Introduction ............................................................................................ 241 Class declaration ................................................................................... 241 Class constructors ................................................................................. 242 Class methods ....................................................................................... 242 Methods inherited .................................................................................. 243 DialogBox Widget Example ................................................................... 244

Event Handling ..................................................................... 249
Event Handler Interfaces ....................................................................... 249 iii Event Methods ....................................................................................... 251 Example ................................................................................................. 251

Custom Widgets ................................................................... 255
Create Custom Widget with Composite Class ....................................... 255

UIBinder ............................................................................... 259
Introduction ............................................................................................ 259 UiBinder workflow .................................................................................. 259 Step 1: Create UI Declaration XML File ................................................. 259 Step 2: Use ui:field for Later Binding ..................................................... 260 Step 3: Create Java counterpart of UI XML ........................................... 260 Step 4: Bind Java UI fields with UiField annotation ................................ 260 Step 5: Bind Java UI with UI XML with UiTemplate annotation ............. 260 Step 6: Create CSS File ........................................................................ 261 Step 7: Create Java based Resource File for CSS File ......................... 261 Step 8: Attach CSS resource in Java UI Code file. ................................ 261 UIBinder Complete Example.................................................................. 261

RPC Communication ............................................................ 269
GWT RPC Components ........................................................................ 269 RPC Communication workflow .............................................................. 270 Step 1: Create a Serializable Model Class ............................................ 270 Step 2: Create a Service Interface ......................................................... 270 Step 2: Create a Async Service Interface .............................................. 271 Step 3: Create a Service Implementation Servlet class ......................... 271 Step 4: Update Web.xml to include Servlet declaration ......................... 271 Step 5: Make the remote procedure call in Application Code ................ 272 RPC Communication Complete Example .............................................. 272

JUnit Integration ................................................................... 278
Download Junit archive .......................................................................... 278 Locate GWT installation folder ............................................................... 278 GWTTestCase Class ............................................................................. 278 Using webAppCreator ............................................................................ 279 Understanding the test class: HelloWorldTest.java ................................ 280 Noteworthy Points.................................................................................. 281 GWT - JUnit Integration Complete Example .......................................... 281 Run test cases in Eclipse using generated launch configurations. ........ 285
RUN THE JUNIT TEST IN DEVELOPMENT MODE. ........................... 285 RUN THE JUNIT TEST IN PRODUCTION MODE. .............................. 286

Debug Application ................................................................ 288
Debugging Example .............................................................................. 288 iii Step 1 - Place BreakPoints .................................................................... 291 Step 2 - Debug Application .................................................................... 292

Internationalization ............................................................... 296
Workflow of internationalizing a GWT Application ................................. 296 Step 1: Create properties files ............................................................... 296 Step 2: Add i18n module to Module Descriptor XML File ...................... 297 Step 3: Create Interface equivalent to properties file ............................. 297 Step 4: Use Message Interface in UI component................................... 297 Internationalization - Complete Example ............................................... 298

History Class ........................................................................ 303
History Management Workflow .............................................................. 303 Step 1: Enable History support .............................................................. 303 Step 2: Add token to History .................................................................. 303 Step 3: Retrive token from History ......................................................... 304 History Class - Complete Example ........................................................ 304

Bookmark Support ............................................................... 308
Bookmarking Example ........................................................................... 308

Logging Framework ............................................................. 313
Types of Logger ..................................................................................... 313 Log Handlers ......................................................................................... 313 Configure Logging in GWT Application .................................................. 314 Use logger to log user actions ............................................................... 314 Logging Framework Example ................................................................ 314

iii

CHAPTER

1

GWTOverview
This chapter describes the basic definition and concepts of Google Web Toolkit.

What is GWT?

G
    

WT is an open source, free development toolkit.

Google Web Toolkit (GWT) is a development toolkit to create RICH Internet Application(RIA). GWT provides developers option to write client side application in JAVA. GWT compiles the code written in JAVA to JavaScript code. Application written in GWT is cross-browser compliant. GWT automatically generates javascript code suitable for each browser. GWT is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0.

Overall, GWT is a framework to build large scale and high performance web appliation while keeping them as easy-to-maintain.

Why to use GWT?

Being Java based, you can use JAVA IDEs like Eclipse to develop GWT applcation. Developers can use code auto-complete/refactoring/navigation/project management and all features of IDEs. GWT provides full debugging capability. Developers can debug the client side application just as an Java Application. GWT provides easy integration with Junit and Maven.

 

TUTORIALSPOINT Simply Easy Learning

Page 1

   

Again being Java based, GWT has a low learning curve for Java Developers. GWT generates optimized javascript code, produces browser's specific javascript code by self. GWT provides Widgets library provides most of tasks required in an application. GWT is extensible and custom widget can be created to cater to application needs.

On top of everything, GWT applications can run on all major browsers and smart phones including Android and iOS based phones/tablets.

Disadvantages of GWT
Though GWT comes with lots of plus points but same time we should consider the following points:

  

Not indexable : Web pages generated by GWT would not be indexed by search engines because these applications are generated dynamically. Not degradable: If your application user disables Javascript then user will just see the basic page and nothing more. Not designer's friendly: GWT is not suitable for web designers who prefer using plain HTML with placeholders for inserting dynamic content at later point in time.

The GWT Components
The GWT framework can be divided into following three major parts:



GWT Java to JavaScript compiler : This is the most important part of GWT which makes it a powerful tool for building RIAs. The GWT compiler is used to translate all the application code written in Java into JavaScript. JRE Emulation library : Google Web Toolkit includes a library that emulates a subset of the Java runtime library. The list includes java.lang, java.lang.annotation, java.math, java.io, java.sql, java.util and java.util.logging





GWT UI building library : This part of GWT consists of many subparts which includes the actual UI components, RPC support, History management, and much more. GWT also provides a GWT Hosted Web Browser which lets you run and execute your GWT applications in hosted mode, where your code runs as Java in the Java Virtual Machine without compiling to JavaScript.



TUTORIALS POINT Simply Easy Learning

Page 2

CHAPTER

2

Environment
This section describes how to setup your system environment before you start using Google Web Toolkit:

T
JDK Memory

his will guide you on how to prepare a development environment to start your

work with GWT Framework. This tutorial will also teach you how to setup JDK, Tomcat and Eclipse on your machine before you setup GWT Framework:

System Requirement
GWT requires JDK 1.6 or higher so the very first requirement is to have JDK installed in your machine. 1.6 or above. no minimum requirement. no minimum requirement. no minimum requirement.

Disk Space Operating System

Follow the given steps to setup your environment to start with GWT application development.

Step 1 - Verify Java installation on your machine
Now open console and execute the following java command. OS Windows Linux Mac Task Open Command Console Open Command Terminal Open Terminal Command c:\> java -version $ java -version machine:~ joseph$ java -version

TUTORIALS POINT Simply Easy Learning

Page 3

Let's verify the output for all the operating systems: OS Windows Generated Output java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing) java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing) java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM)64-Bit Server VM (build 17.0-b17, mixed mode, sharing)

Linux

Mac

Step 2 - Setup Java Development Kit (JDK):
If you do not have Java installed then you can install the Java Software Development Kit (SDK) from Oracle's Java site: Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively. Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example: OS Windows Linux Mac Output Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21 export JAVA_HOME=/usr/local/java-current export JAVA_HOME=/Library/Java/Home

Append Java compiler location to System Path. OS Windows Linux Mac Output Append the string ;%JAVA_HOME%\bin to the end of the system variable, Path. export PATH=$PATH:$JAVA_HOME/bin/ not required

Alternatively, if you use an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE knows where you installed Java, otherwise do proper setup as given document of the IDE.

Step 3 - Setup Eclipse IDE
All the examples in this tutorial have been written using Eclipse IDE. So I would suggest you should have latest version of Eclipse installed on your machine based on your operating system.

TUTORIALS POINT Simply Easy Learning

Page 4

To install Eclipse IDE, download the latest Eclipse binaries from http://www.eclipse.org/downloads/. Once you downloaded the installation, unpack the binary distribution into a convenient location. For example in C:\eclipse on windows, or /usr/local/eclipse on Linux/Unix and finally set PATH variable appropriately. Eclipse can be started by executing the following commands on windows machine, or you can simply double click on eclipse.exe %C:\eclipse\eclipse.exe Eclipse can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine: $/usr/local/eclipse/eclipse After a successful startup, if everything is fine then it should display following result:

Step 4: Install GWT SDK & Plugin for Eclipse
Follow the instructions given at the link Plugin for Eclipse (incl. SDKs) to install GWT SDK & Plugin for Eclipse version installed on your machine. After a successful setup for the GWT plugin, if everything is fine then it should display following screen with google icon marked with red rectangle:

TUTORIALS POINT Simply Easy Learning

Page 5

Step 5: Setup Apache Tomcat:
You can download the latest version of Tomcat from http://tomcat.apache.org/. Once you downloaded the installation, unpack the binary distribution into a convenient location. For example in C:\apache-tomcat-6.0.33 on windows, or /usr/local/apache-tomcat-6.0.33 on Linux/Unix and set CATALINA_HOME environment variable pointing to the installation locations. Tomcat can be started by executing the following commands on windows machine, or you can simply double click on startup.bat %CATALINA_HOME%\bin\startup.bat or C:\apache-tomcat-6.0.33\bin\startup.bat Tomcat can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine: $CATALINA_HOME/bin/startup.sh or /usr/local/apache-tomcat-6.0.33/bin/startup.sh

TUTORIALS POINT Simply Easy Learning

Page 6

After a successful startup, the default web applications included with Tomcat will be available by visiting http://localhost:8080/. If everything is fine then it should display following result

Further information about configuring and running Tomcat can be found in the documentation included here, as well as on the Tomcat web site: http://tomcat.apache.org Tomcat can be stopped by executing the following commands on windows machine: %CATALINA_HOME%\bin\shutdown or C:\apache-tomcat-5.5.29\bin\shutdown Tomcat can be stopped by executing the following commands on Unix (Solaris, Linux, etc.) machine: $CATALINA_HOME/bin/shutdown.sh or /usr/local/apache-tomcat-5.5.29/bin/shutdown.sh

TUTORIALS POINT Simply Easy Learning

Page 7

CHAPTER

3

Applications
This section describes the applications under Google Web Toolkit:

B
   

eforewe start with creating actual HelloWorld application using GWT, let us see

what are the actual parts of a GWT application. A GWT application consists of following four important parts out of which last part is optional but first three parts are mandatory: Module descriptors Public resources Client-side code Server-side code

Sample locations of different parts of a typical gwt application HelloWord will be as shown below: Name Project root Module descriptor Public resources Client-side code Server-side code Location HelloWorld/ src/com/tutorialspoint/HelloWorld.gwt.xml src/com/tutorialspoint/war/ src/com/tutorialspoint/client/ src/com/tutorialspoint/server/

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. Following will be a default module descriptorHelloWorld.gwt.xml for a HelloWorld application:

TUTORIALS POINT Simply Easy Learning

Page 8

--> --> -->

-->

-->

--

2

This adds other gwt module in application just like import does in java applications. Any number of modules can be inherited in this manner. This specifies the name of class which will start loading the GWT Application. Any number of entry-point classes can be added and they are called sequentially in the order in which they appear in the module file. So when the onModuleLoad() of your first entry point finishes, the next entry point is called immediately. This specifies the names of source folders which GWT compiler will search for source compilation. The public path is the place in your project where static resources referenced by your GWT module, such as CSS or images, are stored. The default public path is the public subdirectory underneath where the Module XML File is stored. Automatically injects the external JavaScript file located at the location specified by src. Automatically injects the external CSS file located at the location specified by src.

3

4

5

6 7

TUTORIALS POINT Simply Easy Learning

Page 9

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 element in module configuration file. By default, it is the public subdirectory underneath where the Module XML File is stored. When you compile your application into JavaScript, all the files that can be found on your public path are copied to the module's output directory. The most important public resource is host page which is used to invoke actual GWT application. A typical HTML host page for an application might not include any visible HTML body content at all but it is always expected to include GWT application via a tag as follows: Hello World

Hello World Welcome to first GWT application Following is the sample style sheet which we have included in our host page: body { text-align: center; font-family: verdana, sans-serif; } h1 { font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; }

Client-side code
This is the actual Java code written implementing the business logic of the application and that the GWT compiler translates into JavaScript, which will eventually run inside the browser. The location of these resources can be configured using element in module configuration file. For example Entry Point code will be used as client side code and its location will be specified using . A module entry-point is any class that is assignable to EntryPoint and that can be constructed without parameters. When a module

TUTORIALS POINT Simply Easy Learning

Page 10

is loaded, every entry point class is instantiated and its EntryPoint.onModuleLoad() method gets called. A sample HelloWorld Entry Point class will be as follows: publicclassHelloWorldimplementsEntryPoint{ publicvoid onModuleLoad(){ Window.alert("Hello, World!"); } }

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. Next chapter will make use of all the above mentioned concepts to create HelloWorld application using Eclipse IDE.

TUTORIALS POINT Simply Easy Learning

Page 11

CHAPTER

4

Create Application
This section describes how to create application:

A

s power of GWT lies in Write in Java, Run in JavaScript, we'll be using Java

IDE Eclipse to demonstrate our examples. Let's start with a simple HelloWorld application:

Step 1 - Create Project
The first step is to create a simple Web Application Project using Eclipse IDE. Launch project wizard using the option Google Icon > New Web Application Project....

Now name your project asHelloWorld using the wizard window as follows:

TUTORIALS POINT Simply Easy Learning

Page 12

Unselect Use Google App Engine because we're not using it in this project and leave other default values (keep Generate Sample project code option checked) as such and click Finish Button. Once your project is created successfully, you will have following content in your Project Explorer:

TUTORIALS POINT Simply Easy Learning

Page 13

Here is brief description of all important folders: Folder Location

   src Source code (java classes) files. Client folder containing the client-side specific java classes responsible for client UI display. Server folder containing the server-side java classes responsible for server side processing. Shared folder containing the java model class to transfer data from server to client and vice versa. HelloWorld.gwt.xml, a module descriptor file required for GWT compiler to compile the HelloWorld project.

 

 test Test code (java classes) source files. Client folder containing the java classes responsible to test gwt client side code.



TUTORIALS POINT Simply Easy Learning

Page 14

  war This is the most important part, it represents the actual deployable web application. WEB-INF containing compiled classes, gwt libraries, servlet libraries. HelloWorld.css, project style sheet. HelloWorld.html, hots HTML which will invoke GWT UI Application.

 

Step 2 - Modify Module Descriptor:
HelloWorld.gwt.xml
GWT plugin will create a default module descriptor file src/com.tutorialspoint/HelloWorld.gwt.xml which is given below. For this example we are not modifying it, but you can modify it based on your requirement.

--> -->

Step 3 - Modify Style Sheet: HelloWorld.css
GWT plugin will create a default Style Sheet file war/HelloWorld.css. Let us modify this file to keep our example at simplest level of understaning: body { text-align: center; font-family: verdana, sans-serif; } h1 { font-size:2em; font-weight: bold;

TUTORIALS POINT Simply Easy Learning

Page 15

color:#777777; margin:40px0px70px; text-align: center; }

Step 4 - Modify Host File: HelloWorld.html
GWT plugin will create a default HTML host file war/HelloWorld.html. Let us modify this file to keep our example at simplest level of understaning: Hello World Hello World Welcome to first GWT application You can create more static files like HTML, CSS or images in the same source directory or you can create further sub-directories and move files in those sub-directories and configure those sub-directories in module descriptor of the application.

Step 5 - Modify Entry Point: HelloWorld.java
GWT plugin will create a default Java file src/com.tutorialspoint/HelloWorld.java, which keeps an entry point for the application. Let us modify this file to display "Hello,World!": package com.tutorialspoint.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.Window; publicclassHelloWorldimplementsEntryPoint{ publicvoid onModuleLoad(){ Window.alert("Hello, World!"); } } You can create more Java files in the same source directory to define either entry points or to define helper routines.

Step 6 - Compile Application

TUTORIALS POINT Simply Easy Learning

Page 16

Once you are ready with all the changes done, its time to compile the project. Use the option Google Icon box as shown below: > GWT Compile Project... to launch GWT Compile dialogue

Keep default values intact and click Compile button. If everything goes fine, you will see following output in Eclipse console Compiling module com.tutorialspoint.HelloWorld Compiling 6 permutations Compiling permutation 0... Compiling permutation 1... Compiling permutation 2... Compiling permutation 3... Compiling permutation 4... Compiling permutation 5... Compile of permutations succeeded Linking into C:\workspace\HelloWorld\war\helloworld

TUTORIALS POINT Simply Easy Learning

Page 17

Link succeeded Compilation succeeded -- 33.029s

Step 6 - Run Application
Now click on application. Run application menu and select HelloWorld application to run the

If everything is fine, you must see GWT Development Mode active in Eclipse containing a URL as shown below. Double click the URL to open the GWT application.

Because you are running your application in development mode, so you will need to install GWT plugin for your browser. Simply follow the onscreen instructions to install the plugin. If you already have GWT plugin set for your browser, then you should be able to see the following output:

TUTORIALS POINT Simply Easy Learning

Page 18

Congratulations! you have implemented your first application using Google Web Toolkit (GWT).

TUTORIALS POINT Simply Easy Learning

Page 19

CHAPTER

5

Deploy Application
This section describes how to deploy application under Google Web Toolkit:

T
1 2 3 4 5

his tutorial will explain you how to create an application war file and how to deploy

that in Apache Tomcat Websever root. If you understood this simple example then you will also be able to deploy a complex GWT application following the same steps. Let us have working Eclipse IDE along with GWT plug in place and follow the following steps to create a GWT application: Step Description Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to make sure business logic is working as per the requirements. Finally, zip the content of the war folder of the application in the form of war file and deploy it in Apache Tomcat Webserver. Launch your web application using appropriate URL as explained below in the last step. modified module

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body { text-align: center; font-family: verdana, sans-serif; } h1 { font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World Hello World

I modified HTML a little bit from previous example. Here I created a placeholder ... where we will insert some content using our entry point java class. So let us have following content of Java filesrc/com.tutorialspoint/HelloWorld.java. package com.tutorialspoint.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; public class HelloWorld implementsEntryPoint{ public void onModuleLoad(){ HTML html =new HTML("Welcome to GWT application"); RootPanel.get("gwtContainer").add(html); } } Here we created on basic widgest HTML and added it inside the div tag having id="gwtContainer". We will study different GWT widgets in coming chapters.

TUTORIALS POINT Simply Easy Learning

Page 21

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

Create WAR File
Now our applictaion is working fine and we are ready to export it as a war file. Follow the following steps:

   

Go into your project's war directory C:\workspace\HelloWorld\war Select all the files & folders available inside war directory. Zip all the selected files & folders in a file called HelloWorld.zip. Rename HelloWorld.zip to HelloWorld.war.

Deploy WAR file
    
Stop the tomcat server. Copy the HelloWorld.war file to tomcat installation directory > webapps folder. Start the tomcat server. Look inside webapps directory, there should be a folder helloworld got created. Now HelloWorld.war is successfully deployed in Tomcat Webserver root.

Run Application
TUTORIALS POINT Simply Easy Learning

Page 22

Enter a url in web browser: http://localhost:8080/HelloWorld to launch the application Server name (localhost) and port (8080) may vary as per your tomcat configuration.

TUTORIALS POINT Simply Easy Learning

Page 23

CHAPTER

6

Style with CSS
This section describes CSS with Google Web Toolkit:

G

WT widgets rely on cascading style sheets (CSS) for visual styling. By default,

the class name for each component is gwt-. For example, the Button widget has a default style of gwt-Buttonand similar way TextBox widgest has a default style of gwtTextBox. In order to give all buttons and text boxes a larger font, you could put the following rule in your application's CSS file: .gwt-Button{ font-size:150%;} .gwt-TextBox{ font-size:150%;} By default, neither the browser nor GWT creates default id attributes for widgets. You must explicitly create a unique id for the elements which you can use in CSS. In order to give a particular button with idmy-button-id a larger font, you could put the following rule in your application's CSS file: #my-button-id { font-size: 150%; } To set the id for a GWT widget, retrieve its DOM Element and then set the id attribute as follows: Button b =newButton(); DOM.setElementAttribute(b.getElement(),"id","my-button-id")

CSS Styling APIs
There are many APIs available to hangle CSS setting for any GWT widget. Following are few important APIs which will help you in your day to day web programming using GWT: S.N. API & Description 1 public void setStyleName(java.lang.String style) This method will clear any existing styles and set the widget style to the new CSS class provided using style.

TUTORIALS POINT Simply Easy Learning

Page 24

2

public void addStyleName(java.lang.String style) This method will add a secondary or dependent style name to the widget. A secondary style name is an additional style name that is,so if there were any previous style names applied they are kept. public void removeStyleName(java.lang.String style) This method will remove given style from the widget and leaves any others associated with the widget. public java.lang.String getStyleName() This method gets all of the object's style names, as a space-separated list. public void setStylePrimaryName(java.lang.String style) This method sets the object's primary style name and updates all dependent style names.

3

4

5

For example, let's define two new styles which we will apply to a text: .gwt-Big-Text{ font-size:150%; } .gwt-Small-Text{ font-size:75%; } .gwt-Red-Text{ color:red; } Now you can use setStyleName(Style) to change the default setting to new setting. After applying the below rule, a text's font will become large: txtWidget.setStyleName("gwt-Big-Text"); We can apply a secondary CSS rule on the same widget to change its color as follows: txtWidget.addStyleName("gwt-Red-Text"); Using above method you can add as many styles as you like to apply on a widget. If you remove first style from the button widget then second style will still remain with the text: txtWidget.removeStyleName("gwt-Big-Text");

Primary & Secondary Styles
By default, the primary style name of a widget will be the default style name for its widget class for example gwt-Button for Button widgets. When we add and remove style names using AddStyleName() method, those styles are called secondary styles. The final appearance of a widget is determined by the sum of all the secondary styles added to it, plus its primary style. You set the primary style of a widget with the setStylePrimaryName(String) method. To illustrate, let's say we have a Label widget. In our CSS file, we have the following rules defined: .MyText{ color: blue; }

TUTORIALS POINT Simply Easy Learning

Page 25

.BigText{ font-size: large; } .LoudText{ font-weight: bold; } Let's suppose we want a particular label widget to always display blue text, and in some cases, use a larger, bold font for added emphasis. We could do something like this: // set up our primary style Label someText =newLabel(); someText.setStylePrimaryName("MyText"); ... // later on, to really grab the user's attention someText.addStyleName("BigText"); someText.addStyleName("LoudText"); ... // after the crisis is over someText.removeStyleName("BigText"); someText.removeStyleName("LoudText");

Associating CSS Files
There are multiple approaches for associating CSS files with your module. Modern GWT applications typically use a combination of CssResource and UiBinder. We are using only first approach in our examples.

   

Using a tag in the host HTML page. Using the element in the module XML file. Using a CssResource contained within a ClientBundle. Using an inline element in a UiBinder template.

GWT CSS Example
This example will take you through simple steps to apply different CSS rules on your GWT widgest. Let us have working Eclipse IDE along with GWT plug in place and follow the following steps to create a GWT application: Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic.

TUTORIALS POINT Simply Easy Learning

Page 26

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } .gwt-Green-Border{ border:1px solid green; } .gwt-Blue-Border{ border:1px solid blue; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World HTML Widget Demonstration

Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate use of HTML widget. package com.tutorialspoint.client;

TUTORIALS POINT Simply Easy Learning

Page 42

import import import import

com.google.gwt.core.client.EntryPoint; com.google.gwt.user.client.ui.HTML; com.google.gwt.user.client.ui.RootPanel; com.google.gwt.user.client.ui.VerticalPanel;

public class HelloWorld implements EntryPoint{ public void onModuleLoad(){ // create two HTML widgets HTML html1 = new HTML("This is first GWT HTML widget using tag of html."); HTML html2 = new HTML("This is second GWT HTML widget using tag of html."); // use UIObject methods to set HTML widget properties. html1.addStyleName("gwt-Green-Border"); html2.addStyleName("gwt-Blue-Border"); // add widgets to the root panel. VerticalPanel panel =newVerticalPanel(); panel.setSpacing(10); panel.add(html1); panel.add(html2); RootPanel.get("gwtContainer").add(panel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

IMAGE
Introduction
The Image widget displays an image at a given URL.The image widget can be in 'unclipped' mode (the default mode) or 'clipped' mode. In clipped mode, a viewport is overlaid on top of the image so that a subset of the image will be displayed. In unclipped

TUTORIALS POINT Simply Easy Learning

Page 43

mode, there is no viewport - the entire image will be visible. Methods will operate differently depending on the mode that the image is in. These differences are detailed in the documentation for each method.

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.Image class: public lass Image extends Widget implements SourcesLoadEvents,HasLoadHandlers, HasErrorHandlers,SourcesClickEvents, HasClickHandlers,HasAllMouseHandlers, SourcesMouseEvents

CSS style rules
Following default CSS Style rule will be applied to all the Image widget. You can override it as per your requirements. .gwt-Image{}

Class constructors
S.N. Constructor & Description 1 2 3 4 Image() Creates an empty image. protected Image(Element element) This constructor may be used by subclasses to explicitly use an existing element. Image(java.lang.String url) Creates an image with the specified url. Image(java.lang.String html, int left, int top, int width, int height) Creates a clipped image with a specified URL and visibility rectangle.

Class methods
S.N. Function name & Description 1 2 3 4 5 6 7 void addClickListener(ClickListener listener) Adds a listener interface to receive click events. void addLoadListener(LoadListener listener) Adds a listener interface to receive load events. void addMouseListener(MouseListener listener) Adds a listener interface to receive mouse events. void addMouseWheelListener(MouseWheelListener listener) Gets this widget's parent panel. int getHeight() Gets the height of the image. int getOriginLeft() Gets the horizontal co-ordinate of the upper-left vertex of the image's visibility rectangle. int getOriginTop() Gets the vertical co-ordinate of the upper-left vertex of the image's visibility rectangle.

TUTORIALS POINT Simply Easy Learning

Page 44

8 9 10 11

java.lang.String getUrl() Gets the URL of the image. int getWidth() Gets the width of the image. void onBrowserEvent(Event event) Removes a previously added listener interface. static void prefetch(java.lang.String url) Causes the browser to pre-fetch the image at a given URL. void removeClickListener(ClickListener listener) This method is called immediately before a widget will be detached from the browser's document. void removeLoadListener(LoadListener listener) Removes a previously added listener interface. void removeMouseListener(MouseListener listener) Removes a previously added listener interface. void removeMouseWheelListener(MouseWheelListener listener) Removes a previously added listener interface. void setUrl(java.lang.String url) Sets the URL of the image to be displayed. void setUrlAndVisibleRect(java.lang.String url, int left, int top, int width, int height) Sets the url and the visibility rectangle for the image at the same time. void setVisibleRect(int left, int top, int width, int height) Sets the visibility rectangle of an image. static Image wrap(Element element) Creates a Image widget that wraps an existing element.

12

13 14 15 16 17 18 19

Methods inherited
This class inherits methods from the following classes:

  

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget java.lang.Object

Image Widget Example
This example will take you through simple steps to show usage of a Image Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter: Step Description 1 2 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged.

TUTORIALS POINT Simply Easy Learning

Page 45

3

Compile and run the application to verify the result of the implemented logic. modified module

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

TUTORIALS POINT Simply Easy Learning

Page 54

--> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } .gwt-Button{ color:red; } .gwt-Green-Button{ color:green; } .gwt-Blue-Button{ color:blue; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World Button Widget Demonstration

Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate use of Button widget. package com.tutorialspoint.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.dom.client.ClickEvent;

TUTORIALS POINT Simply Easy Learning

Page 55

import import import import import

com.google.gwt.event.dom.client.ClickHandler; com.google.gwt.user.client.Window; com.google.gwt.user.client.ui.Button; com.google.gwt.user.client.ui.RootPanel; com.google.gwt.user.client.ui.VerticalPanel;

public class HelloWorld implements EntryPoint{ public void onModuleLoad(){ //create buttons Button redButton =new Button("Red"); Button greenButton =new Button("Green"); Button blueButton =new Button("Blue"); // use UIObject methods to set button properties. redButton.setWidth("100px"); greenButton.setWidth("100px"); blueButton.setWidth("100px"); greenButton.addStyleName("gwt-Green-Button"); blueButton.addStyleName("gwt-Blue-Button"); //add a clickListener to the button redButton.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ Window.alert("Red Button clicked!"); } }); //add a clickListener to the button greenButton.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ Window.alert("Green Button clicked!"); } }); //add a clickListener to the button blueButton.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ Window.alert("Blue Button clicked!"); } }); // Add button to the root panel. VerticalPanel panel =new VerticalPanel(); panel.setSpacing(10); panel.add(redButton); panel.add(greenButton); panel.add(blueButton); RootPanel.get("gwtContainer").add(panel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

TUTORIALS POINT Simply Easy Learning

Page 56

When you click Click Me button, it will show an alert message Hello World!

PushButton
Introduction
The PushButton widget represents a standard push button with custom styling.

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.PushButton class: public class PushButton extends CustomButton

CSS style rules
Following default CSS Style rules will be applied to all the PushButton widget. You can override it as per your requirements. .gwt-PushButton-up {} .gwt-PushButton-down {} .gwt-PushButton-up-hovering {} .gwt-PushButton-down-hovering {} .gwt-PushButton-up-disabled {} .gwt-PushButton-down-disabled {}

Class constructors
S.N. Constructor & Description

TUTORIALS POINT Simply Easy Learning

Page 57

1 2 3 4 5 6 7 8

PushButton() Constructor for PushButton. PushButton(Image upImage) Creates a PushButton with up state image. PushButton(Image upImage, ClickListener listener) Creates a PushButton with up state image and clickListener. PushButton(Image upImage, Image downImage) Creates a PushButton with up state image. PushButton(Image upImage, Image downImage, ClickListener listener) Creates a PushButton with up state image. PushButton(java.lang.String upText) Creates a PushButton with up state text. PushButton(java.lang.String upText, ClickListener listener) Creates a PushButton with up state text and clicklistener. PushButton(java.lang.String upText, java.lang.String downText) Creates a PushButton with up state and down state text. PushButton(java.lang.String upText, java.lang.String downText, ClickListener listener) Creates a PushButton with up state, down state text and click listener.

8

Class methods
S.N. Function name & Description 1 protected void onClick() Called when the user finishes clicking on this button. protected void onClickCancel() Called when the user aborts a click in progress; for example, by dragging the mouse outside of the button before releasing the mouse button. protected void onClickStart() Called when the user begins to click on this button.

2

3

Methods inherited
This class inherits methods from the following classes:

    

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.FocusWidget com.google.gwt.user.client.ui.CustomWidget java.lang.Object

TUTORIALS POINT Simply Easy Learning

Page 58

PushButton Widget Example
This example will take you through simple steps to show usage of a PushButton Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Applicationchapter: Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic. modified module

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } .gwt-ToggleButton-up { color:green; } .gwt-ToggleButton-down { color:blue; } .gwt-ToggleButton-up-hovering { color:pink; } .gwt-ToggleButton-down-hovering { color:aqua; } .gwt-ToggleButton-up-disabled { color:lime; } .gwt-ToggleButton-down-disabled { color:maroon; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World ToggleButton Widget Demonstration

Let us have following file src/com.tutorialspoint/HelloWorld.java which ToggleButton widget.

content of will demonstrate

use

Java of

public class HelloWorld implements EntryPoint{

TUTORIALS POINT Simply Easy Learning

Page 64

public void onModuleLoad(){ //create toggle buttons ToggleButton toggleButton =new ToggleButton("Click Me!"); ToggleButton toggleButton1 =new ToggleButton("Click Me!"); //disable a toggle button toggleButton1.setEnabled(false); //add a clickListener to the toggle button toggleButton.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ Window.alert("Hello World!"); } }); // Add toggle button to the root panel. VerticalPanel panel =new VerticalPanel(); panel.setSpacing(10); panel.add(toggleButton); panel.add(toggleButton1); RootPanel.get("gwtContainer").add(panel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

TUTORIALS POINT Simply Easy Learning

Page 65

When you click Click Me button, it will show an alert message Hello World! You can see color of button text will change with your interaction.

  

Hover over the button, color will be pink. Press the button, color will be blue. Release the button, button will remain down.

CheckBox
Introduction
The Checkbox widget represents a standard checkbox.

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.CheckBox class: public class CheckBox extends ButtonBase implements HasName

CSS style rules
Following default CSS Style rules will be applied to all the CheckBox widget. You can override it as per your requirements. .gwt-CheckBox{} .gwt-CheckBox-disabled {}

Class constructors
S.N. Constructor & Description 1 2 3 4 CheckBox() Constructor for CheckkBox. CheckBox(Element element) This constructor may be used by subclasses to explicitly use an existing element. CheckBox(java.lang.String label) Creates a check box with the specified text label. CheckBox(java.lang.String label, boolean asHTML) Creates a check box with the specified text label and set its contents as HTML.

Class methods
S.N. Function name & Description 1 java.lang.String getName() Gets the widget's name.

TUTORIALS POINT Simply Easy Learning

Page 66

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

int getTabIndex() Gets the widget's position in the tab index. java.lang.String getText() Gets this object's text. boolean isChecked() Determines whether this check box is currently checked. boolean isEnabled() Gets whether this widget is enabled. protected void onEnsureDebugId(java.lang.String baseID) Affected Elements: -label = label next to checkbox. protected void onLoad() This method is called when a widget is attached to the browser's document. protected void onUnload() This method is called when a widget is detached from the browser's document. protected void replaceInputElement(Element elem) Replace the current input element with a new one. void setAccessKey(char key) Sets the widget's 'access key'. void setChecked(boolean checked) Checks or unchecks this check box. void setEnabled(boolean enabled) Sets whether this widget is enabled. void setFocus(boolean focused) Explicitly focus/unfocus this widget. void setHTML(java.lang.String html) Sets this object's contents via HTML. void setName(java.lang.String name) Sets the widget's name. void setTabIndex(int index) Sets the widget's position in the tab index. void setText(java.lang.String text) Sets this object's text. void sinkEvents(int eventBitsToAdd) Adds a set of events to be sunk by this object. java.lang.String getHTML() Gets this object's contents as HTML.

Methods inherited
This class inherits methods from the following classes:

 

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget

TUTORIALS POINT Simply Easy Learning

Page 67

 

com.google.gwt.user.client.ui.FocusWidget java.lang.Object

CheckBox Widget Example
This example will take you through simple steps to show usage of a CheckBox Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter:
Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic.

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

-->

TUTORIALS POINT Simply Easy Learning

Page 98

-->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } .gwt-RichTextArea{ padding:10px; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World RichTextArea Widget Demonstration

Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate use of TextBox widget. package com.tutorialspoint.client; import import import import com.google.gwt.core.client.EntryPoint; com.google.gwt.user.client.ui.RichTextArea; com.google.gwt.user.client.ui.RootPanel; com.google.gwt.user.client.ui.VerticalPanel;

public class HelloWorld implementsEntryPoint{ public void onModuleLoad(){ //create RichTextArea elements RichTextArea richTextArea =new RichTextArea();

TUTORIALS POINT Simply Easy Learning

Page 99

richTextArea.setHeight("200"); richTextArea.setWidth("200"); //add text to text area richTextArea.setHTML("Hello World!"+ "Be Happy!Stay Cool!"); // Add text boxes to the root panel. VerticalPanel panel =new VerticalPanel(); panel.add(richTextArea); RootPanel.get("gwtContainer").add(panel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

TUTORIALS POINT Simply Easy Learning

Page 100

FileUpload
Introduction
The FileUpload widget wraps the HTML element. This widget must be used with FormPanel if it is to be submitted to a server.

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.FileUpload class: public class FileUpload Extends Widget Implements HasName,HasChangeHandlers

CSS style rules
Following default CSS Style rules will be applied to all the TextBox widget. You can override it as per your requirements. .gwt-FileUpload{}

Class constructors
S.N. Constructor & Description 1 2 FileUpload() Constructs a new file upload widget. FileUpload(Element element) This constructor may be used by subclasses to explicitly use an existing element.

Class methods
S.N. Function name & Description 1 2 3 4 5 6 7 HandlerRegistration addChangeHandler(ChangeHandler handler) Adds a ChangeEvent handler. java.lang.String getFilename() Gets the filename selected by the user. java.lang.String getName() Gets the widget's name. boolean isEnabled() Gets whether this widget is enabled. void onBrowserEvent(Event event) Fired whenever a browser event is received. void setEnabled(boolean enabled) Sets whether this widget is enabled. void setName(java.lang.String name) Sets the widget's name.

TUTORIALS POINT Simply Easy Learning

Page 101

8

static FileUpload wrap(Element element) Creates a FileUpload widget that wraps an existing element.

Methods inherited
This class inherits methods from the following classes:

  

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget java.lang.Object

FileUpload Widget Example
This example will take you through simple steps to show usage of a FileUpload Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter:
Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic.

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World CellTable Widget Demonstration

TUTORIALS POINT Simply Easy Learning

Page 152

Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate use of CellTable widget. package com.tutorialspoint.client; import java.util.Arrays; import java.util.Date; import java.util.List; import com.google.gwt.cell.client.DateCell; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.cellview.client.CellTable; import com.google.gwt.user.cellview.client.Column; import com.google.gwt.user.cellview.client .HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; import com.google.gwt.user.cellview.client.TextColumn; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.view.client.SelectionChangeEvent; import com.google.gwt.view.client.SingleSelectionModel; public class HelloWorld implements EntryPoint{ /** * A simple data type that represents a contact. */ private static class Contact{ private final String address; private final Date birthday; private finalString name; public Contact(String name,Date birthday,String address){ this.name = name; this.birthday = birthday; this.address = address; } } /** * The list of data to display. */ private static final List CONTACTS =Arrays.asList( new Contact("John",new Date(80,4,12),"123 Fourth Avenue"), new Contact("Joe",new Date(85,2,22),"22 Lance Ln"), new Contact("George",new Date(46,6,6),"1600 Pennsylvania Avenue")); public void onModuleLoad(){ // Create a CellTable. CellTable table =new CellTable(); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); // Add a text column to show the name. TextColumn nameColumn = new TextColumn(){ @Override public String getValue(Contactobject){ return object.name; }

TUTORIALS POINT Simply Easy Learning

Page 153

}; table.addColumn(nameColumn,"Name"); // Add a date column to show the birthday. DateCell dateCell =new DateCell(); Column dateColumn =new Column(dateCell){ @Override public Date getValue(Contact object){ return object.birthday; } }; table.addColumn(dateColumn,"Birthday"); // Add a text column to show the address. TextColumn addressColumn =new TextColumn(){ @Override public String getValue(Contact object){ return object.address; } }; table.addColumn(addressColumn,"Address"); // Add a selection model to handle user selection. final SingleSelectionModel selectionModel =newSingleSelectionModel(); table.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler(){ public void onSelectionChange(SelectionChangeEvent event){ Contact selected = selectionModel.getSelectedObject(); if(selected !=null){ Window.alert("You selected: "+ selected.name); } } }); // Set the total row count. This isn't strictly necessary, // but it affects paging calculations, so its good habit to // keep the row count up to date. table.setRowCount(CONTACTS.size(),true); // Push the data into the widget. table.setRowData(0, CONTACTS); VerticalPanel panel =newVerticalPanel(); panel.setBorderWidth(1); panel.setWidth("400"); panel.add(table); // Add the widgets to the root panel. RootPanel.get().add(panel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

TUTORIALS POINT Simply Easy Learning

Page 154

CellBrowser
Introduction
The CellBrowser widget represents a browsable view of a tree in which only a single node per level may be open at one time.

Class declaration
Following is the for com.google.gwt.user.cellview.client.CellBrowser class: declaration

public class CellBrowser extends AbstractCellTree implements ProvidesResize,RequiresResize,HasAnimation

TUTORIALS POINT Simply Easy Learning

Page 155

Class constructors
S.N. Constructor & Description 1 CellBrowser(TreeViewModel viewModel, T rootValue) Construct a new CellBrowser. CellBrowser(TreeViewModel viewModel, T rootValue, CellBrowser.Resources resources) Construct a new CellBrowser with the specified CellBrowser.Resources.

2

Class methods
S.N. Function name & Description 1 2 3 4 5 6 7 8 9 protected Widget createPager(HasData display) Create a pager to control the list view. int getDefaultColumnWidth() Get the default width of new columns. int getMinimumColumnWidth() Get the minimum width of columns. TreeNode getRootTreeNode() Get the root TreeNode. boolean isAnimationEnabled() Returns true if animations are enabled, false if not. void onBrowserEvent(Event event) Fired whenever a browser event is received. void onResize() This method must be called whenever the implementor's size has been modified. void setAnimationEnabled(boolean enable) Enable or disable animations. void setDefaultColumnWidth(int width) Set the default width of new columns. void setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionP olicy policy) Set the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy. void setMinimumColumnWidth(int minWidth) Set the minimum width of columns.

10

11

Methods inherited
This class inherits methods from the following classes:

  

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.Composite

TUTORIALS POINT Simply Easy Learning

Page 156

 

com.google.gwt.user.cellview.client.AbstractCellTree java.lang.Object

CellBrowser Widget Example
This example will take you through simple steps to show usage of a CellBrowser Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Applicationchapter: Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.jav a as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic. modified module

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

TUTORIALS POINT Simply Easy Learning

Page 196

--> -->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } .deckpanel { border:1px solid #BBBBBB; padding:3px; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World DeckPanel Widget Demonstration

Let us have following file src/com.tutorialspoint/HelloWorld.java which DeckPanel widget. package com.tutorialspoint.client; import import import import import import import

content of will demonstrate

use

Java of

com.google.gwt.core.client.EntryPoint; com.google.gwt.event.dom.client.ClickEvent; com.google.gwt.event.dom.client.ClickHandler; com.google.gwt.user.client.ui.Button; com.google.gwt.user.client.ui.DeckPanel; com.google.gwt.user.client.ui.HorizontalPanel; com.google.gwt.user.client.ui.Label;

TUTORIALS POINT Simply Easy Learning

Page 197

import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.VerticalPanel; public class HelloWorld implements EntryPoint{ public void onModuleLoad(){ // Create DeckPanel widget final DeckPanel deckPanel =new DeckPanel(); deckPanel.setSize("300px","120px"); deckPanel.setStyleName("deckpanel"); // Create lables to add to deckpanel Label label1 =new Label("This is first Page"); Label label2 =new Label("This is second Page"); Label label3 =new Label("This is third Page"); // Add labels to deckpanel deckPanel.add(label1); deckPanel.add(label2); deckPanel.add(label3); //show first label deckPanel.showWidget(0); //create button bar HorizontalPanel buttonBar =new HorizontalPanel(); buttonBar.setSpacing(5); // create button and add click handlers // show different labels on click of different buttons Button button1 =new Button("Page 1"); button1.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ deckPanel.showWidget(0); } }); Button button2 =newButton("Page 2"); button2.addClickHandler(newClickHandler(){ @Override public void onClick(ClickEvent event){ deckPanel.showWidget(1); } }); Button button3 =new Button("Page 3"); button3.addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event){ deckPanel.showWidget(2); } }); buttonBar.add(button1); buttonBar.add(button2); buttonBar.add(button3); VerticalPanel vPanel =new VerticalPanel(); vPanel.add(deckPanel); vPanel.add(buttonBar); // Add the widgets to the root panel. RootPanel.get().add(vPanel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

TUTORIALS POINT Simply Easy Learning

Page 198

DockPanel
Introduction
The DockPanel widget represents a panel that lays its child widgets out "docked" at its outer edges, and allows its last widget to take up the remaining space in its center.

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.DockPanel class:

@Deprecated public class DockPanel extends CellPanel

TUTORIALS POINT Simply Easy Learning

Page 199

implements HasAlignment

Class constructors
S.N. Constructor & Description 1 DockPanel() Constructor for DockPanel.

Class methods
S.N. Function name & Description 1 2 3 4 void add(Widget widget, DockPanel.DockLayoutConstant direction) Deprecated. Adds a widget to the specified edge of the dock. HasHorizontalAlignment.HorizontalAlignmentConstant getHorizontalAlignment() Deprecated. Gets the horizontal alignment. HasVerticalAlignment.VerticalAlignmentConstant getVerticalAlignment() Deprecated. Gets the vertical alignment. DockPanel.DockLayoutConstant getWidgetDirection(Widget w) Deprecated. Gets the layout direction of the given child widget. protected void onEnsureDebugId(java.lang.String baseID) Deprecated. DockPanel supports adding more than one cell in a direction, so an integer will be appended to the end of the debug id. boolean remove(Widget w) Deprecated. Removes a child widget. void setCellHeight(Widget w, java.lang.String height) Deprecated. Sets the height of the cell associated with the given widget, related to the panel as a whole. void setCellHorizontalAlignment(Widget w, HasHorizontalAlignment.HorizontalAlignmentConstant align) Deprecated. Sets the horizontal alignment of the given widget within its cell. void setCellVerticalAlignment(Widget w, HasVerticalAlignment.VerticalAlignmentConstant align) Deprecated. Sets the vertical alignment of the given widget within its cell. void setCellWidth(Widget w, java.lang.String width) Deprecated. Sets the width of the cell associated with the given widget, related to the panel as a whole. void setHorizontalAlignment(HasHorizontalAlignment.HorizontalAlignmentConstant align) Deprecated. Sets the default horizontal alignment to be used for widgets added to this panel. void setVerticalAlignment(HasVerticalAlignment.VerticalAlignmentConstant align) Deprecated. Sets the default vertical alignment to be used for widgets added to this panel.

5

6

7

8

9

10

11

12

Methods inherited
This class inherits methods from the following classes:



com.google.gwt.user.client.ui.UIObject

TUTORIALS POINT Simply Easy Learning

Page 200

    

com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.Panel com.google.gwt.user.client.ui.ComplexPanel com.google.gwt.user.client.ui.CellPanel java.lang.Object

DockPanel Widget Example
This example will take you through simple steps to show usage of a DockPanel Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter:
Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic.

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

--> --> -->

-->

-->

Following is the content of the modified Style Sheet file war/HelloWorld.css. body{ text-align: center; font-family: verdana, sans-serif; } h1{ font-size:2em; font-weight: bold; color:#777777; margin:40px0px70px; text-align: center; } Following is the content of the modified HTML host file war/HelloWorld.html. Hello World FormPanel Widget Demonstration

Let us have following file src/com.tutorialspoint/HelloWorld.java which FormPanel widget. package com.tutorialspoint.client; import import import import import import import import import import import import import import

content of will demonstrate

use

Java of

com.google.gwt.core.client.EntryPoint; com.google.gwt.event.dom.client.ClickEvent; com.google.gwt.event.dom.client.ClickHandler; com.google.gwt.user.client.Window; com.google.gwt.user.client.ui.Button; com.google.gwt.user.client.ui.DecoratorPanel; com.google.gwt.user.client.ui.FileUpload; com.google.gwt.user.client.ui.FormPanel; com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent; com.google.gwt.user.client.ui.FormPanel.SubmitEvent; com.google.gwt.user.client.ui.ListBox; com.google.gwt.user.client.ui.RootPanel; com.google.gwt.user.client.ui.TextBox; com.google.gwt.user.client.ui.VerticalPanel;

TUTORIALS POINT Simply Easy Learning

Page 232

public class HelloWorld implements EntryPoint{ public void onModuleLoad(){ // Create a FormPanel and point it at a service. final FormPanel form =new FormPanel(); form.setAction("/myFormHandler"); // Because we're going to add a FileUpload widget, // we'll need to set the form to use the POST method, // and multipart MIME encoding. form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel =new VerticalPanel(); panel.setSpacing(10); form.setWidget(panel);
// Create a TextBox, giving it a name so that it will be submitted.

final TextBox tb =new TextBox(); tb.setWidth("220"); tb.setName("textBoxFormElement"); panel.add(tb); // Create a ListBox, giving it a name and // some values to be associated with its options. ListBox lb =new ListBox(); lb.setName("listBoxFormElement"); lb.addItem("item1","item1"); lb.addItem("item2","item2"); lb.addItem("item3","item3"); lb.setWidth("220"); panel.add(lb); // Create a FileUpload widget. FileUpload upload =new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); // Add a 'submit' button. panel.add(newButton("Submit",new ClickHandler(){ @Override public void onClick(ClickEvent event){ form.submit(); } })); // Add an event handler to the form. form.addSubmitHandler(new FormPanel.SubmitHandler(){ @Override public void onSubmit(SubmitEvent event){ // This event is fired just before the form is submitted. // We can take this opportunity to perform validation. if(tb.getText().length()==0){ Window.alert("The text box must not be empty"); event.cancel(); } } }); form.addSubmitCompleteHandler(newFormPanel. SubmitCompleteHandler(){

TUTORIALS POINT Simply Easy Learning

Page 233

@Override public void onSubmitComplete(SubmitCompleteEvent event){ // When the form submission is successfully completed, // this event is fired. Assuming the service returned // a response of type text/html, we can get the result // here. Window.alert(event.getResults()); } }); DecoratorPanel decoratorPanel =new DecoratorPanel(); decoratorPanel.add(form); // Add the widgets to the root panel. RootPanel.get().add(decoratorPanel); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

PopupPanel
TUTORIALS POINT Simply Easy Learning

Page 234

Introduction
The PopupPanel widget represents a panel that can pop up over other widgets. It overlays the browser's client area (and any previously-created popups).

Class declaration
Following is the declaration for com.google.gwt.user.client.ui.PopupPanel class: public class PopupPanel extends SimplePanel implements SourcesPopupEvents,EventPreview, HasAnimation,HasCloseHandlers

Class constructors
S.N. Constructor & Description 1 2 3 PopupPanel() Creates an empty popup panel. PopupPanel(boolean autoHide) Creates an empty popup panel, specifying its auto-hide property. PopupPanel(boolean autoHide, boolean modal) Creates an empty popup panel, specifying its auto-hide and modal properties.

Class methods
S.N. Function name & Description 1 void addAutoHidePartner(Element partner) Mouse events that occur within an autoHide partner will not hide a panel set to autoHide. HandlerRegistration addCloseHandler(CloseHandler handler) Adds a CloseEvent handler. void addPopupListener(PopupListener listener) Deprecated. Use addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler) instead void center() Centers the popup in the browser window and shows it. protected Element getContainerElement() Override this method to specify that an element other than the root element be the container for the panel's child widget. protected Element getGlassElement() Get the glass element used by this PopupPanel. java.lang.String getGlassStyleName() Gets the style name to be used on the glass element. int getOffsetHeight() Gets the panel's offset height in pixels. int getOffsetWidth() Gets the panel's offset width in pixels.

2

3

4

5

6 7 8 9

TUTORIALS POINT Simply Easy Learning

Page 235

10 11 12 13 14 15 16

int getPopupLeft() Gets the popup's left position relative to the browser's client area. int getPopupTop() Gets the popup's top position relative to the browser's client area. protected Element getStyleElement() Template method that returns the element to which style names will be applied. java.lang.String getTitle() Gets the title associated with this object. void hide() Hides the popup and detaches it from the page. void hide(boolean autoClosed) Hides the popup and detaches it from the page. boolean isAnimationEnabled() Returns true if animations are enabled, false if not. boolean isAutoHideEnabled() Returns true if the popup should be automatically hidden when the user clicks outside of it. boolean isAutoHideOnHistoryEventsEnabled() Returns true if the popup should be automatically hidden when the history token changes, such as when the user presses the browser's back button. boolean isGlassEnabled() Returns true if a glass element will be displayed under the PopupPanel. boolean isModal() Returns true if keyboard or mouse events that do not target the PopupPanel or its children should be ignored. boolean isPreviewingAllNativeEvents() Returns true if the popup should preview all native events, even if the event has already been consumed by another popup. boolean isShowing() Determines whether or not this popup is showing. boolean isVisible() Determines whether or not this popup is visible. boolean onEventPreview(Event event) Deprecated. Use onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent) instead boolean onKeyDownPreview(char key, int modifiers) Deprecated. Use onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent) instead boolean onKeyPressPreview(char key, int modifiers) Deprecated. Use onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent) instead boolean onKeyUpPreview(char key, int modifiers)

17

18

19

20

21

22 23

24

25

26

27

TUTORIALS POINT Simply Easy Learning

Page 236

Deprecated. Use onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent) instead 28 29 protected void onPreviewNativeEvent(Event.NativePreviewEvent event) protected void onUnload() This method is called immediately before a widget will be detached from the browser's document. void removeAutoHidePartner(Element partner) Remove an autoHide partner. void removePopupListener(PopupListener listener) Deprecated. Use the HandlerRegistration.removeHandler() method on the object returned by addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler) instead void setAnimationEnabled(boolean enable) Enable or disable animations. void setAutoHideEnabled(boolean autoHide) Enable or disable the autoHide feature. void setAutoHideOnHistoryEventsEnabled(boolean enabled) Enable or disable autoHide on history change events. void setGlassEnabled(boolean enabled) When enabled, the background will be blocked with a semi-transparent pane the next time it is shown. void setGlassStyleName(java.lang.String glassStyleName) Sets the style name to be used on the glass element. void setHeight(java.lang.String height) Sets the height of the panel's child widget. void setModal(boolean modal) When the popup is modal, keyboard or mouse events that do not target the PopupPanel or its children will be ignored. void setPopupPosition(int left, int top) Sets the popup's position relative to the browser's client area. void setPopupPositionAndShow(PopupPanel.PositionCallback callback) Sets the popup's position using a PopupPanel.PositionCallback, and shows the popup. void setPreviewingAllNativeEvents(boolean previewAllNativeEvents) When enabled, the popup will preview all native events, even if another popup was opened after this one. void setTitle(java.lang.String title) Sets the title associated with this object. void setVisible(boolean visible) Sets whether this object is visible. void setWidget(Widget w) Sets this panel's widget. void setWidth(java.lang.String width) Sets the width of the panel's child widget.

30

31

32 33 34

35

36 37

38

39

40

41

42 43 44 45

TUTORIALS POINT Simply Easy Learning

Page 237

46

void show() Shows the popup and attach it to the page. void showRelativeTo(UIObject target) Normally, the popup is positioned directly below the relative target, with its left edge aligned with the left edge of the target.

47

Methods inherited
This class inherits methods from the following classes:

    

com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.Panel com.google.gwt.user.client.ui.SimplePanel java.lang.Object

PopupPanel Widget Example
This example will take you through simple steps to show usage of a PopupPanel Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Applicationchapter:
Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic.

Following is the content of the descriptor src/com.tutorialspoint/HelloWorld.gwt.xml. --> --> -->

--> --> -->

--> --> -->

--> --> -->

Hello World Custom Widget Demonstration Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate creation of a Custom widget. package com.tutorialspoint.client; import import import import import import import import com.google.gwt.core.client.EntryPoint; com.google.gwt.event.dom.client.ClickEvent; com.google.gwt.event.dom.client.ClickHandler; com.google.gwt.user.client.ui.CheckBox; com.google.gwt.user.client.ui.Composite; com.google.gwt.user.client.ui.HorizontalPanel; com.google.gwt.user.client.ui.RootPanel; com.google.gwt.user.client.ui.TextBox;

public class HelloWorld implements EntryPoint{ /** * A composite of a TextBox and a CheckBox that optionally enables it.

TUTORIALS POINT Simply Easy Learning

Page 256

*/ private static class OptionalTextBox extends Composite implements ClickHandler{ private TextBox textBox =new TextBox(); private CheckBox checkBox =new CheckBox(); private boolean enabled =true; public boolean isEnabled(){ return enabled; } public void setEnabled(boolean enabled){ this.enabled = enabled; } /** * Style this widget using .optionalTextWidget CSS class. * Style textbox using .optionalTextBox CSS class. * Style checkbox using .optionalCheckBox CSS class. * Constructs an OptionalTextBox with the given caption * on the check. * @param caption the caption to be displayed with the check box */ public OptionalTextBox(String caption){ // place the check above the text box using a vertical panel. HorizontalPanel panel =new HorizontalPanel(); // panel.setBorderWidth(1); panel.setSpacing(10); panel.add(checkBox); panel.add(textBox); // all composites must call initWidget() in their constructors. initWidget(panel); //set style name for entire widget setStyleName("optionalTextWidget"); //set style name for text box textBox.setStyleName("optionalTextBox"); //set style name for check box checkBox.setStyleName("optionalCheckBox"); textBox.setWidth("200"); // Set the check box's caption, and check it by default. checkBox.setText(caption); checkBox.setValue(enabled); checkBox.addClickHandler(this); enableTextBox(enabled,checkBox.getValue()); } public void onClick(ClickEvent event){ if(event.getSource()== checkBox){ // When the check box is clicked, //update the text box's enabled state. enableTextBox(enabled,checkBox.getValue()); } } private void enableTextBox(boolean enable,boolean isChecked){ enable =(enable && isChecked)||(!enable &&!isChecked); textBox.setStyleDependentName("disabled",!enable); textBox.setEnabled(enable); } } public void onModuleLoad(){

TUTORIALS POINT Simply Easy Learning

Page 257

// Create an optional text box and add it to the root panel.
OptionalTextBox otb =new OptionalTextBox("Want to explain the solution?");

otb.setEnabled(true); RootPanel.get().add(otb); } }

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

You can notice following points

   

Creation of Custom Widget by extending Composite widget is pretty easy. We've created a widget with GWT inbuilt widgets, TextBox and CheckBox thus using the concept of reusability. TextBox get disabled/enabled depending on state of checkbox. We've provided an API to enable/disable the control. We've exposed internal widgets styles via documented CSS styles.

TUTORIALS POINT Simply Easy Learning

Page 258

13
UIBinder
This section describes the UI Binder under Google Web Toolkit:

CHAPTER

T
     

he UIBinder under Google Web Toolkit is a framework which allows developers to

build GWT applications.

Introduction
The UiBinder is a framework designed to separate Functionality and View of User Interface. The UiBinder framework allows developers to build gwt applications as HTML pages with GWT widgets configured throughout them. The UiBinder framework makes easier collaboration with UI designers who are more comfortable with XML, HTML and CSS than Java source code The UIBinder provides a declarative way of defining User Interface. The UIBinder seperates the programmic logic from UI. The UIBinder is similar to what JSP is to Servlets.

UiBinder workflow Step 1: Create UI Declaration XML File
Create a XML/HTML based User a Login.ui.xml file in our example. Interface declaration file. We've created

TUTORIALS POINT Simply Easy Learning

Page 259

...

Step 2: Use ui:field for Later Binding
Use ui:field attribute in XML/HTML element to relate UI field in XML with UI field in JAVA file for later binding.

Step 3: Create Java counterpart of UI XML
Create Java based counterpart of XML based layout by extending Composite widget. We've created aLogin.java file in our example. package com.tutorialspoint.client; ... public class Login extends Composite{ ... }

Step 4: Bind Java UI fields with UiField annotation use @UiField annotation in Login.java to designate counterpart class members to bind to XMLbased fields in Login.ui.xml public class Login extends Composite{ ... @UiField Label completionLabel1; @UiField Label completionLabel2; ... }

Step 5: Bind Java UI with UI XML with UiTemplate annotation
Instruct GWT to bind java based component Login.java and layout Login.ui.xml using @UiTemplate annotation public class Login extends Composite{ private static LoginUiBinder uiBinder = GWT.create(LoginUiBinder.class); /* * @UiTemplate is not mandatory but allows multiple XML templates * to be used for the same widget. * Default file loaded will be .ui.xml */ @UiTemplate("Login.ui.xml") interface LoginUiBinder extends UiBinder{ } ... }

XML

based

TUTORIALS POINT Simply Easy Learning

Page 260

Step 6: Create CSS File
Create an external CSS fileLogin.css and Java based Resource LoginResources.java file equivalent to css styles .blackText { font-family:Arial,Sans-serif; color:#000000; font-size:11px; text-align: left; } ...

Step 7: Create Java based Resource File for CSS File package com.tutorialspoint.client; ... public interface LoginResources extends ClientBundle{ public interface MyCss extends CssResource{ String blackText(); ... } @Source("Login.css") MyCss style(); }

Step 8: Attach CSS resource in Java UI Code file.
Attach an external class Login.java CSS fileLogin.css using Contructor of Java based widget public Login(){ this.res = GWT.create(LoginResources.class); res.style().ensureInjected(); initWidget(uiBinder.createAndBindUi(this)); }

UIBinder Complete Example
This example will take you through simple steps to show usage of a UIBinder in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter:
Step Description 1 2 3 Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter. Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged. Compile and run the application to verify the result of the implemented logic. the modified module

Following is the content of descriptor src/com.tutorialspoint/HelloWorld.gwt.xml.

TUTORIALS POINT Simply Easy Learning

Page 261

--> --> --> -->

Following is the content of the modified HTML host file war/HelloWorld.html. Hello World UiBinder Demonstration Now create a new UiBinder template and owner class (File -> New -> UiBinder).

TUTORIALS POINT Simply Easy Learning

Page 262

Choose the client package for the project and then name it Login. Leave all of the other defaults.Click Finish button and the plugin will create a new UiBinder template and owner class.

TUTORIALS POINT Simply Easy Learning

Page 263

Now create Login.css file in the src/com.tutorialspoint/client package and place the following contents in it
.blackText { font-family:Arial,Sans-serif; color:#000000; font-size:11px; text-align: left; } .redText { font-family:Arial,Sans-serif; color:#ff0000; font-size:11px; text-align: left; } .loginButton { border:1px solid #3399DD; color:#FFFFFF; background:#555555; font-size:11px; font-weight: bold; margin:05px00; padding:4px10px5px;

TUTORIALS POINT Simply Easy Learning

Page 264

text-shadow:0-1px0#3399DD; } .box { border:1px solid #AACCEE; display: block; font-size:12px; margin:005px; padding:3px; width:203px; } .background { background-color:#999999; border:1px none transparent; color:#000000; font-size:11px; margin-left:-8px; margin-top:5px; padding:6px; }

Now create LoginResources.java file in the src/com.tutorialspoint/client package and place the following contents in it package com.tutorialspoint.client; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.CssResource; public interface LoginResources extends ClientBundle{ /** * Sample CssResource. */ public interface MyCss extends CssResource{ String blackText(); String redText(); String loginButton(); String box(); String background(); } @Source("Login.css") MyCss style(); }

Replace the contents of Login.ui.xml in src/com.tutorialspoint/client package with the following

TUTORIALS POINT Simply Easy Learning

Page 265

Replace the contents of Login.java in src/com.tutorialspoint/client package with the following package com.tutorialspoint.client; import import import import import import import import import import import import com.google.gwt.core.client.GWT; com.google.gwt.event.dom.client.ClickEvent; com.google.gwt.event.logical.shared.ValueChangeEvent; com.google.gwt.uibinder.client.UiBinder; com.google.gwt.uibinder.client.UiField; com.google.gwt.uibinder.client.UiHandler; com.google.gwt.uibinder.client.UiTemplate; com.google.gwt.user.client.Window; com.google.gwt.user.client.ui.Composite; com.google.gwt.user.client.ui.Label; com.google.gwt.user.client.ui.TextBox; com.google.gwt.user.client.ui.Widget;

public class Login extends Composite{ private static LoginUiBinder uiBinder = GWT.create(LoginUiBinder.class); /* * @UiTemplate is not mandatory but allows multiple XML templates * to be used for the same widget. * Default file loaded will be .ui.xml */ @UiTemplate("Login.ui.xml") interface LoginUiBinder extends UiBinder{ } @UiField(provided =true) final LoginResources res; public Login(){ this.res = GWT.create(LoginResources.class); res.style().ensureInjected(); initWidget(uiBinder.createAndBindUi(this)); } @UiField TextBox loginBox; @UiField TextBox passwordBox; @UiField Label completionLabel1; @UiField Label completionLabel2; private Boolean tooShort =false; /*

TUTORIALS POINT Simply Easy Learning

Page 266

* Method name is not relevant, the binding is done according to the class of the parameter. */ @UiHandler("buttonSubmit") void doClickSubmit(ClickEvent event){ if(tooShort){ Window.alert("Login Successful!"); }else{ Window.alert("Login or Password is too short!"); } } @UiHandler("loginBox") void handleLoginChange(ValueChangeEvent event){ if(event.getValue().length()

Similar Documents

Premium Essay

College Homework Help

...COLLEGE HOMEWORK HELP Through college homework help, we aim to provide you with all necessary material and solution you require for the understanding of whole of your college’s curriculum. If you are searching for homework help from experts who are well-read in the subjects of mathematics, calculus, statistics and algebra you have come to right place. All scholars are verified degree holders who have years of experience helping students with their maths, accountancy and English problems. Here you can submit anything from simple queries to complex or lengthy assignments and receive expert guidance to help you develop fully-worked solutions. We can assist with any type of project - homework assignments, practice questions, laboratory write-ups, and more. Every subject has its own characteristics like English you need to learn writing skills and in maths you need to learn formulae but every subject demands a single similar thing that is dedication and if you are dedicated to actually learn a subject our experts are equally dedicated to teach you that. Generally, classroom lectures are not enough for the student to be able to cope up with the complexities of problems given for homework, and that is why additional homework help is so essential. College homework help provided by expert and qualified tutors has been always proved to be of immense help and has often been back bone support for students who do well in class. Having problems with your homework or feeling too lazy to figure...

Words: 404 - Pages: 2

Premium Essay

Psy Tut 1

...        PSY1004F/PSY1006F Work piece 3 Biopsychology and Memory Name & Surname:       Student Number:                    Tutorial group:                  Tutor:                      Date:         _________________________________________________________________________________________________ 1. There are a number of clients at the Shady Pines Nursing Home who have suffered neurological damage. Given the limited, and admittedly oversimplified, information provided in your handbook about the patients at Shady Pines Nursing Home, make an educated guess as to the part of the brain that has been damaged. a. Anna: Click here to enter text. b. Lindiwe: Click here to enter text. c. Luke: Click here to enter text. d. Tarryn: Click here to enter text. e. Matthew: Click here to enter text. f. Benson: Click here to enter text. g. Craig: Click here to enter text. [15 marks] 2. Read the examples outlined in your tutorial handbook and for each one (i) identify the probable cause of forgetting, (ii) provide a definition for the probable cause, and (iii) provide an explanation of the cause with reference to the example. ...

Words: 252 - Pages: 2

Free Essay

Apa Assignment

...APA Assignment CSS101 February 13, 2013 The purpose of this essay is to tell you about the resources that are available to me and the amount of help they have provided. I will discuss all of the resources and provide all of the resources and give great information why I have chosen them. There a few program like SHARC, Tutoring Center, and my local library. I will now discuss the information I’ve come across in this essay. At Stevens Henager College that have a program called SHARC. This resource is very helpful and reliable in many ways. I constantly use this resource to help me out on a couple of assignment’s I’ve had problems with. I believe that SHARC is being a crucial part of my college life as I try to peruse my future career. They are there to help in any way they can just to prepare you for your future job. SHARC provides so much important information to help any student succeed. Another resource I truly count on is the tutoring center. They have plenty of certified tutors and tons or other academic tutors and tutor sessions. This tutoring center has helped me so many times on my classes and assignments. I believe that the tutoring center will be a huge influence and a constant stop throughout my college life. It would always be a place to go to get things I’ve had problems with and I know that they’re to help. The last resource I use is my local library. It’s always been a great place to go since I was in high school to get any...

Words: 376 - Pages: 2

Premium Essay

Dennis

... Contents Paper Description and Aims .............................................................................................................. 1 Learning Outcomes .......................................................................................................................... 1 Teaching & Support Staff.................................................................................................................. 2 Course Delivery ................................................................................................................................. 3 i. ii. i. ii. iii. iv. Lectures................................................................................................................................ 3 Tutorials ............................................................................................................................... 3 Prescribed textbook ............................................................................................................. 4 Blackboard ........................................................................................................................... 4 Podcast of lectures ............................................................................................................... 5 Student Webmail.................................................................................................................. 5 Course Learning Resources ......................................................

Words: 3081 - Pages: 13

Premium Essay

Peer Tutoring and the Conversation of Mankind.Doc

...87 .,~. Peer Tutoring and the "Conversation of Mankind" by Kenneth A. Bruffee The beginnings of peer tutoring lie in practice, not in theory. A decade or so ago, faculty and administrators in a few institutions around the country became aware that, increasingly, students entering college had difficulty doing as well in academic studies as their abilities suggested they should be able to do. Some of these students were in many ways poorly prepared academically. Many more of them, however, had on paper excellent secondary preparation. The common denominator among the poorly prepared and the apparently well prepared seemed to be that, for cultural reasons we may not yet fully under­ stand, all these students had difficulty adapting to the traditional or "normal" conventions of the college classroom. One symptom of the difficulty was that many of these students refuSed .help when it was offered. Mainly, colleges offered ancillary programs staffed by professionals. Students avoided them in droves. Many solutions to this problem were suggested and tried, from mandated programs to sink-or-swim. One idea that seemed at the time among the most exotic and unlikely (that is, in the jargon of the Sixties, among the most "radical") turned out to work rather well. Some of us had guessed that students were refusing the help we were providing because it seemed to them merely an extension of the work, the expectations, and above all the social structure of traditional classroom learning. And...

Words: 5727 - Pages: 23

Premium Essay

Void

...MODULE TITLE : Strategic Management CODE : BB309 PRE-REQUISITE : BB112 Fundamental of Management CREDIT HOURS : 3 LECTURER : Remie Johan (remie@ucsiuniversity.edu.my) ASSIGNMENT: CASE STUDY (30%) – British Petroleum Introduction: Students (based on groups) will be given a case prior to the allocated tutorials presentation session. Students are expected to answer all questions listed in the case. This assignment is aimed at providing students the necessary skills in understanding and applying the appropriate management concepts in solving real-life business scenarios. Instructions to students: 1. Work in groups of 5 people (max). Assignments that do not adhere to these group requirements will not be accepted. Students must submit their Group Name List / Assignment Cover Page (Appendix 1) latest by Week 3 (during tutorial). 2. Students must stick to the same tutorial class throughout the semester, as group/ individual activities will be conducted during each tutorial. Group marks will be given during tutorials. Written Report Format • Table of Content 1. Introduction 1. An introduction of the case and concept 2. Content 1. Answer to question # 1 2. Answer to question # 2 3. Answer to question # 3 (if any) 4. Answer to question # 4 (if any) 3. Summary / conclusion about the case | ...

Words: 717 - Pages: 3

Free Essay

Um Papers to Follow

...Click on Content > Course Content and read the Start Here information. * Next, go to Content > Start Here and review the orientation notes. Follow the directions and complete the Classroom Walk through if you have not done so already. Please log in two to three times per week and read the News items here, keep up with the course materials and assignments, and turn in your work on time. Note that all assignments are due Sunday night at 11:59 PM (EST) Required Reading for week 1: * Module 1 * Onboarding for this course and for graduate study at UMUC Assignments for week 1: * Watch Dean Krause's Welcome Video * Post your brief bio in the Introduce Yourself! Discussion * Complete the Academic Integrity Tutorial *...

Words: 575 - Pages: 3

Free Essay

Communications

...WILFRID LAURIER UNIVERSITY WATERLOO, ON COMMUNICATION STUDIES CS 101A — CANADIAN COMMUNICATION IN CONTEXT FALL 2015 Instructor Email Office Location Office Hours Phone Dr. Nathan Rambukkana nrambukkana@wlu.ca DAWB 3-136 Monday 12:00 – 1:00 or by appointment 519 884 0710 x4346 ∆ COURSE FORMAT Lecture Tutorials A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 Thursday 4:00 to 5:50 Location: BA 201 Time Friday 8:30-9:20 Friday 9:30-10:20 Friday 10:30-11:20 Friday 11:30-12:20 Friday 12:30-1:20 Friday 8:30-9:20 Friday 9:30-10:20 Friday 10:30-11:20 Friday 11:30-12:20 Friday 12:30-1:20 Thursday 6:30-7:20 Thursday 7:30-8:20 Thursday 6:30-7:20 Thursday 7:30-8:20 Tutorial Leader Copland, Kayla Copland, Kayla Pope, Amara Brown, Sami Brown, Sami Gupta, Alison Gupta, Alison Naraghi, Erika Naraghi, Erika Pope, Amara Zaman, Syeda Zaman, Syeda Bull, Katie Bull, Katie 1 Locations Seminary S102 Seminary S102 Seminary S102 Seminary S102 Seminary S102 Peters P2027 Peters P2027 Peters P2027 Peters P2027 Peters P2027 Seminary S102 Seminary S102 Peters P2027 Peters P2027 Our time each week will divided between lectures, group discussions and, occasionally, the screening of relevant documentaries/other material. The readings for each lecture should be completed by the time of class. ∆ COURSE OVERVIEW Boilerplate Course Description: An introduction to the key issues in Canadian communication...

Words: 2263 - Pages: 10

Free Essay

Web 236 Learning Consultant - Tutorialrank.Com

...more course tutorials visit www.tutorialrank.com Tutorial Purchased: 5 Times, Rating: A+ WEB 236 Week 1 DQS part 1/3 WEB 236 Week 1 DQS part 2/3 WEB 236 Week 1 DQS part 3/3 WEB 236 Week 1 One Weekly Summary WEB 236 Week 2 DQS part 1/2 WEB 236 Week 2 DQS part 2/2 WEB 236 Week 2 Two Weekly Summary WEB 236 Week 2 Individual Assignment: Website Purpose and Architecture Plan- please add own images WEB 236 Week 3 DQS part 1/2 WEB 236 Week 3 DQS part 2/2 WEB 236 Week 3 Individual Assignment: Website Navigation and Development Plan- Please Add Own Images WEB 236 Week 4 Individual Assignment: Website Content Plan- Please Add Own Images WEB 236 Week 4 Learning Team Assignment: Research and Drafting: Develop Recommendations for Re-Design WEB 236 Week 4 DQS WEB 236 Week 4 Four Weekly Summary WEB 236 Week 5 Learning Team Assignment: Website Evaluation Paper and Prototype for Re-Design ----------------------------------------------------- WEB 236 Week 1 DQS part 1/3(UOP) For more course tutorials visit www.tutorialrank.com Tutorial Purchased: 0 Times, Rating: No Rating WEB 236 Week 1 DQS part 1/3 ------------------------------------------------- WEB 236 Week 1 DQS part 2/3(UOP) For more course tutorials visit www.tutorialrank.com Tutorial Purchased: 1 Times, Rating: A+ WEB 236 Week 1 DQS part 2/3 ----------------------------------------------- WEB 236 Week 1 DQS part 3/3(UOP) For more course tutorials visit www.tutorialrank.com Tutorial Purchased:...

Words: 297 - Pages: 2

Free Essay

Ac 553 Assignment Week 5 – a+ Grade

...20: Corporations may elect a calendar year, Question 22: Corporations are allowed to net long-term Problem 55: a. There are no tax consequences to Susan at transfer b. The corporation will recognize c. Susan basis in Problem 62: The corporation’s taxable This tutorial aims to provide answers of questions given in chapter number 14 of AC 553 Week 5 course. Home Work Hour aims to provide quality study notes and tutorials to the students of AC 553 Assignment Week 5 – A+ Grade in order to ace their studies. AC 553 ASSIGNMENT WEEK 5 – A+ GRADE To purchase this visit here: http://www.nerdypupil.com/product/ac-553-assignment-week-5/ Contact us at: nerdypupil@gmail.com AC 553 ASSIGNMENT WEEK 5 AC 553 Assignment Week 5 – Chapter 14 Question 4: Code Sec. 351 allows Question 20: Corporations may elect a calendar year, Question 22: Corporations are allowed to net long-term Problem 55: a. There are no tax consequences to Susan at transfer b. The corporation will recognize c. Susan basis in Problem 62: The corporation’s taxable This tutorial aims to provide answers of questions given in chapter number 14 of AC 553 Week 5 course. Home Work Hour aims to provide quality study notes and tutorials to the students of AC 553 Assignment Week 5 – A+ Grade in order to ace their studies. AC 553 ASSIGNMENT WEEK 5 – A+ GRADE To purchase this visit here: http://www.nerdypupil.com/product/ac-553-assignment-week-5/ Contact us at: nerdypupil@gmail.com AC 553 ASSIGNMENT...

Words: 545 - Pages: 3

Free Essay

Gen 300 Uop Course Tutorial/Tutorialrank

...GEN 300 Entire Course (UOP) For more course tutorials visit www.tutorialrank.com Tutorial Purchased: 3 Times, Rating: A+ GEN 300 Ethics in an Academic Environment Assignment POWERPOINT ONLY GEN 300 Team Dynamics Instructions GEN 300 Effects of Technology Essay GEN 300 Research,Summary, and Paraphrase Activity GEN 300 Ethics in an Academic Environment Assignment PAPER ONLY GEN 300 Final Paper on Team Dynamics GEN 300 Student Web Scavenger Hunt GEN 300 Week 1 DQs GEN 300 Week 2 DQs GEN 300 Week 3 DQs GEN 300 Week 4 DQs GEN 300 Week 5 DQs ............................................................................................................................................................... GEN 300 Effects of Technology Essay (UOP) For more course tutorials visit www.tutorialrank.com Tutorial Purchased: 3 Times, Rating: A+ Technology and the changes it brings can have a very big effect on our lives. Which technological change has had the largest effect on life in this country? Why? Prepare at least a 350-word essay explaining the technology you have chosen and how it has affected our lives. As you write your paper, remember your essay will be scored based on how well you address the following: Develop a multi-paragraph response to the assigned topic that clearly communicates your controlling idea to the audience. Support your controlling idea with meaningful examples, reasons, and information based upon your research or...

Words: 1275 - Pages: 6

Free Essay

My Year Abroad – Brisbane, Australia 2005/2006

...anyone wanted a housemate. Here, I found two Norwegian girls looking for a third, we started talking and I got the room. Now, I am located in a very modern, pretty, three-room apartment in Kangaroo Point, close to both the city and QUT. The apartment also comes with a shared pool and BBQ-facilities. I pay $130 ($1 = 5 NKr. approx.) pr. week, which is a reasonable price for a place like this. Prices vary depending on what area you want to stay in and how many people you’d like to share with. Electricity comes as an addition every third month, and we also have an internet and telephone line we have to pay. Subjects and timetables You choose your subjects prior to departure, but you still have to confirm them and enrol in lectures and tutorials when you have arrived, the university will help...

Words: 3082 - Pages: 13

Free Essay

Porter Forces

...MARKETING & RETAIL DIVISION MGT9A3: BUSINESS IN THE 21ST CENTURY SCQF Level: 8, SCQF Credit: 22 Pre-requisite: MGT9A2 AUTUMN 2013 Module coordinator: Student support: Teaching Staff: MODULE AIMS Carol Marshall, (3A40) carol.marshall@stir.ac.uk Lynne McCulloch (3B44) l.a.mcculloch@stir.ac.uk K Davies, J Joseph, C Marshall, S Mawson, C Taylor The first two foundation modules examined the firm and the external environment. The emphasis for the module is the management of organisations in the 21st century. As such, this module concentrates on the management of the functional areas of the business, namely operations management, human resource management and marketing within the broader context of the changing organisation and the global economy. MODULE LEARNING OBJECTIVES By the end of this module, through completion of the assessment, attendance at lectures and participation in seminars you will have gained knowledge and understanding of:  the changing nature of the global economy and its impact on management,  operations management and organisational aspects of the business,  the future for managing human resources  the changing nature of the market place, marketing and consumer behaviour Also, you will have developed skills in being able to:  think critically, conceptually and contextually,  select and apply theoretical academic models,  search and select appropriate reading material,  use case studies to apply theoretical models to real life  present...

Words: 2031 - Pages: 9

Free Essay

Communications Styles

...of Phoenix Material Communication Styles Worksheet You spent the past few days exploring the resources available to students at University of Phoenix, and you want to share what you learned with a friend who is interested in enrolling. Write a 150- to 200-word e-mail to your friend summarizing the resources available to students. Hey Lizette I wanted to tell you about all the great resources that are available to students at the University of Phoenix! One thing I like about this school is the great resources online, especially the online school library. In the library you can find all sorts of help. They have a whole section for you to get help on your writing skills and grammar skills. They have everything from videos tutorials to small game writing grammar quiz games. They also have a math department that helps you improve on your math skills and it's called the "Center for Mathematics". In the "Center for Mathematics" you can find live online tutoring! Which means that you will have someone online there with you tutoring you and if you have a question, you can submit your question right there and then and the tutor will answer it. In the University Of Phoenix online library you can also find a program tool called "River point Writer" this tool helps you format your papers. If you feel that you need more help on your writing skills, grammar skills, math skills or anything else the online website has a "Program Section" where you can enroll into free school workshops...

Words: 632 - Pages: 3

Free Essay

Casual vs Academic Writing

...Associate Level Material Appendix A Communication Styles Worksheet You spent the past few days exploring the resources available to students at University of Phoenix, and you want to share what you learned with a friend who is interested in enrolling. * Write a 150- to 200-word e-mail to your friend summarizing the resources available to students. * * Hey Dan! * * I know you’re thinking of goin to UoP. I have been learning about all the resources available. There are lots. * * The CWE is probably the best. It’s located in the library section. It has tutorials, sample papers, and writing & style guides. CWE can help with grammar and spelling, APA formatting and check for plagiarism. * * There’s also a resource for math. Here you’re able to review math topics, complete worksheets and there’s answer booklets. Live math tutors are available to help. There are videos to show how to do math problems. * * There’s a skills & career center too. Here there are resources to help with writing cover letters and resumes. * * There are so many ways to research topics in the library too. There’s a specialized and general resource. Ebooks are available as well as dictionaries, thesis, and encyclopedias. * There’s also videos too. * * There are many on line communities in all areas so you can chat with other students. * So check out UoP! It will be great! * * Lori * * You asked...

Words: 471 - Pages: 2