WA 2. GWT Martin Klíma



Similar documents
Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

Google Web Toolkit. Introduction to GWT Development. Ilkka Rinne & Sampo Savolainen / Spatineo Oy

The Google Web Toolkit (GWT): Declarative Layout with UiBinder Basics

ShoreTel Enterprise Contact Center 8 Installing and Implementing Chat

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Fast, Easy, Beautiful: Pick Three Building User Interfaces with Google Web Toolkit. Chris Schalk October 24, 2007

AJAX and jmaki for Web 2.0 Development using Java. Inyoung Cho Java Technology Evangelist Sun Microsystems, Inc.

Rich User Interfaces for Web-Based Corporate Applications

How to develop your own app

place/business fetch details, removefromfavorite () function, 189 search button handler bind, B BlackBerry build environment

Macromedia Dreamweaver 8 Developer Certification Examination Specification

Fast track to HTML & CSS 101 (Web Design)

Wakanda Studio Features

SUBJECT CODE : 4074 PERIODS/WEEK : 4 PERIODS/ SEMESTER : 72 CREDIT : 4 TIME SCHEDULE UNIT TOPIC PERIODS 1. INTERNET FUNDAMENTALS & HTML Test 1

Rich Web Applications in Server-side Java without Plug-ins or JavaScript

Client-side Development using HTML, Javascript and CSS

Preface. Motivation for this Book

Google App Engine f r o r J av a a v a (G ( AE A / E J / )

DreamFactory & Modus Create Case Study

Getting Started Guide with WIZ550web

How To Use Dreamweaver With Your Computer Or Your Computer (Or Your Computer) Or Your Phone Or Tablet (Or A Computer)

Performance Testing for Ajax Applications

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

Google Web Toolkit (GWT) Architectural Impact on Enterprise Web Application

Developing Web Views for VMware vcenter Orchestrator

CONFIGURING A WEB SERVER AND TESTING WEBSPEED

JBoss Portlet Container. User Guide. Release 2.0

Rich Internet Applications

Enterprise Application Development In Java with AJAX and ORM

How To Use Titanium Studio

How To Create A Website Template On Sitefinity

How To Customize A Forum On Vanilla Forum On A Pcode (Forum) On A Windows (For Forum) On An Html5 (Forums) On Pcode Or Windows 7 (Forforums) On Your Pc

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

10CS73:Web Programming

An introduction to creating Web 2.0 applications in Rational Application Developer Version 8.0

ASP.NET Using C# (VS2012)

Debugging Ajax Pages: Firebug

Operational Decision Manager Worklight Integration

1. User Guide API overview addon - xml Definition addon.background addon.background.script

Web Container Components Servlet JSP Tag Libraries

How To Write A Web Server In Javascript

Adding Panoramas to Google Maps Using Ajax

Chapter 1 Introduction to web development and PHP

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

Advanced Event Viewer Manual

Credits: Some of the slides are based on material adapted from

Web Application Development

4.2 Understand Microsoft ASP.NET Web Application Development

Microsoft Expression Web

QuickDNS 4.6 Installation Instructions

5.1 Features Denver CO 80202

Java the UML Way: Integrating Object-Oriented Design and Programming

Sabre Red Apps. Developer Toolkit Overview. October 2014

The Google Web Toolkit (GWT): Overview & Getting Started

Lab 0 (Setting up your Development Environment) Week 1

Agenda. 1. ZAPms Konzept. 2. Benutzer-Kontroller. 3. Laout-Aufbau. 4. Template-Aufbau. 6. Konfiguration. 7. Module.

Front-End Performance Testing and Optimization

SelectSurvey.NET Developers Manual

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

HP AppPulse Mobile. Adding HP AppPulse Mobile to Your Android App

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

Web Applications Testing

Building A Very Simple Website

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

LICENSE4J FLOATING LICENSE SERVER USER GUIDE

OPENTABLE GROUP SEARCH MODULE GETTING STARTED ADD RESERVATIONS TO YOUR WEBSITE

VIRTUAL LABORATORY: MULTI-STYLE CODE EDITOR

Introduction to web development and JavaScript

LICENSE4J LICENSE MANAGER USER GUIDE

<Insert Picture Here>

Android Application Development: Hands- On. Dr. Jogesh K. Muppala

VB.NET - WEB PROGRAMMING

SQL-Ajax Client a Tool Managing the Database of the Google Web Toolkit Framework

Google Web Toolkit GWT

WA2262 Applied Data Science and Big Data Analytics Boot Camp for Business Analysts. Classroom Setup Guide. Web Age Solutions Inc.

Web Applications. For live Java training, please see training courses at

Web Page Redirect. Application Note

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

Accessing Data with ADOBE FLEX 4.6

Course Number: IAC-SOFT-WDAD Web Design and Application Development

Web-JISIS Reference Manual

Budget Event Management Design Document

Step One Check for Internet Connection

About ZPanel. About the framework. The purpose of this guide. Page 1. Author: Bobby Allen Version: 1.1

TIME SCHEDULE OBJECTIVES

IT6503 WEB PROGRAMMING. Unit-I

Short notes on webpage programming languages

Example. Represent this as XML

Java with Eclipse: Setup & Getting Started

Selenium Automation set up with TestNG and Eclipse- A Beginners Guide

WIRIS quizzes web services Getting started with PHP and Java

Joomla! Actions Suite

Developer Tutorial Version 1. 0 February 2015

RIA Overview for Windows 2000, 2002

DNNCentric Custom Form Creator. User Manual

Android Development Setup [Revision Date: 02/16/11]

WEB DEVELOPMENT IA & IB (893 & 894)

Introduction to web development using XHTML and CSS. Lars Larsson. Today. Course introduction and information XHTML. CSS crash course.

Rich-Internet Anwendungen auf Basis von ColdFusion und Ajax

Transcription:

WA 2 GWT Martin Klíma

GWT What is it? Google Web Toolkig Compiler from Java to JavaScript + HTML Set of JavaScript and Java scripts / classes Development environment SDK Integration with IDE Eclipse, Netbeans, Driving idea: Let s code everything in just one language Java Client side will be translated as needed Write the GUI in a Swing style Use the classical event handlers in GUI

Architecture AJAX in the main role Java code Client code Asynchronous communication Server side Java code

GWT GWT is pronounced gwit Open source project with Apache Licence 2.0 Created by Google Many inspired and derived projects Vaadin Smart GWT Sencha GXT IDE integration GWT4NB for NetBeans Links: www.gwtproject.org WA 2 4

GWT Modules Project divided to models A module is a coherent functionality Java like naming convention Each module has a descriptor in XML.gwt.xml Inheritance Entry-point class Source paths classes will be translated to javascript Class paths External JavaScript CSS Servlets, other properties

How does it work? gwt.properties Main.gwt.xml gwt.module entry-point class cz.cvut.fel.client.mainentrypoint GWT Compiler HTLM+JavaScript HTLM+JavaScript HTLM+JavaScript HTLM+JavaScript HTLM+JavaScript Deferred Binding

GWT Properties # The name of the module to compile gwt.module=cz.cvut.fel.dama # Folder within the web app context path where the output # of the GWT module compilation will be stored. # This setting is only used for GWT 1.5. For newer versions please use # the rename-to attribute in the GWT module file (.gwt.xml). gwt.output.dir=/cz.cvut.fel.dama # Script output style: OBF[USCATED], PRETTY, or DETAILED gwt.compiler.output.style=obf # Additional JVM arguments for the GWT compiler gwt.compiler.jvmargs=-xmx256m # Specifies the number of local workers to use whe compiling permutations and module(s) gwt.compiler.local.workers=1 # The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, gwt.compiler.loglevel=warn # Script output style: OBF[USCATED], PRETTY, or DETAILED gwt.shell.output.style=obf # The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, gwt.shell.loglevel=warn # Additional JVM arguments for the GWT shell/gwt hosted mode (GWT 1.6) # Add -d32 here and use at least GWT 1.7.1 to debug on a Mac # (32-bit JRE is required by GWT for debugging) gwt.shell.jvmargs=-xmx256m # GWT version: 1.5,1.6,1.7 or 2.0 gwt.version=2.0 # GWT 2.0 only # Specifies the TCP port for the code server gwt.shell.code.server.port=9997 # GWT 2.0 only # Specifies the TCP port for the embedded web server gwt.shell.port=8888

GWT - module entry point <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd"> <module> <inherits name="com.google.gwt.user.user"/> <inherits name='com.google.gwt.user.theme.standard.standard'/> <!-- Inherit the default GWT style sheet. You can change --> <!-- the theme of your GWT application by uncommenting --> <!-- any one of the following lines. --> <!-- <inherits name='com.google.gwt.user.theme.standard.standard'/> --> <!-- <inherits name="com.google.gwt.user.theme.chrome.chrome"/> --> <!-- <inherits name="com.google.gwt.user.theme.dark.dark"/> --> <entry-point class="cz.cvut.fel.client.damaentrypoint"/> <source path="client"/> <source path="shared"/> <!-- Do not define servlets here, use web.xml --> </module> Main class Client package Classes schared for client-server communication

Class loading 1. Browser loads the starting HTML page 2. Will interpret the script tag <script src= <Module Name>.nocache.js >, and load the JavaScript 3. In JavaScript there is the deferred binding condition leading to loading particular.cache.html 4..cache.html creates a hidden <iframe> and loads into it 5. After loading.cache.html the main application code is started

Loading HTML page example <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link type="text/css" rel="stylesheet" href="dama.css"> <title>dáma na webu</title> <!-- Nahrání klientské logiky v javascriptu --> <script type="text/javascript" language="javascript" src="cz.cvut.fel.dama/cz.cvut.fel.dama.nocache.js"></script> </head> <body> <!-- iframe pro podporu historie --> <iframe src="javascript:''" id=" gwt_historyframe" tabindex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <h1>webová dáma</h1> <div id="ovladani"></div> <div id="sachovnice"></div> </body> </html>

Example client code The entry point is a java class implementing EntryPoint interface Interface EntryPoint onmoduleload() Implements Class MyEntryPoint onmoduleload() My UI here

Implementation package cz.cvut.fel.client; import com.google.gwt.core.client.entrypoint; import com.google.gwt.user.client.ui.button; import com.google.gwt.user.client.ui.label; import com.google.gwt.user.client.ui.rootpanel; import com.google.gwt.event.dom.client.clickevent; import com.google.gwt.event.dom.client.clickhandler; public class MainEntryPoint implements EntryPoint { Code is similar to Swing public MainEntryPoint() { public void onmoduleload() { final Label label = new Label("Hello, GWT!!!"); final Button button = new Button("Click me!"); UI on the client side driven by events button.addclickhandler(new ClickHandler() { public void onclick(clickevent event) { label.setvisible(!label.isvisible()); ); RootPanel.get().add(button); RootPanel.get().add(label);

USER INTERFACE

UI similar to Swing RootPanel container of other components FlowPanel simple <div> on the page HTMLPanel builds HTML structure FormPanel a form ScrollPanel panel with scroll PopupPanel, DialogBox - dialogs Grid, FlexTable tables LayoutPanel, DockLayoutPanel, SplitLayoutPanel, StackLayoutPanel, TabLayoutPanel, More info here: http://www.gwtproject.org/javadoc/latest/

Attention GWT layout works well only in standard browser mode, avoid quirk mode.

GUI components Button TextBox Tree RichTextArea

Events public void anonclickhandlerexample() { Button b = new Button("Click Me"); b.addclickhandler(new ClickHandler() { Annonymous internal class public void onclick(clickevent event) { // handle the click event ); attention use the final modifier class MojeTrida implements ClickHandler { Jiný public způsob void onclick(clickevent event) { // tady si odchytnu udalost a udelam s ni co potrebuji

SERVER COMMUNICATION

GWT - RPC RPC = Remote Procedure Call calling server code from client code Client JavaScript Server Servlet Asynchronous communication using AJAX Serialized objects mediate the communication char, byte, short, int, long, boolean, float, double String, Date, Character, Byte, Short, Integer, Long, Boolean, Float, Double array of serialized values serialized class (IsSerializable or java.io.serializable) a class having at leas one serializable subclass

GWT RPC cont. Synchronous interface Asynchronous interface Implementation of asynchnronous interface on server = contract Calling the asynchronous interface by java code from the client Implementation of synchronous interface by the server

GWT - RPC Client Server GWT PozpatkuServiceAsync create (Class trida) Client code final PozpatkuServiceAsync pozpatkuserviceasync = GWT.create(PozpatkuService.class); pozpatkuserviceasync.pozpatku(textbox.gettext(), new AsyncCallback<String>() { public void onfailure(throwable caught) { // udelej neco pri chybe public void onsuccess(string result) { // udelame neco s vracenym retezcem ); Synchronní rozhraní String pozpatku(string s) RemoteServiceServlet processcall(string s) Server code public class PozpatkuServiceImpl extends RemoteServiceServlet implements PozpatkuService { public String pozpatku(string s) { StringBuffer reverse = new StringBuffer(s.length()); for (int i = (s.length() - 1); i >= 0; i--) { reverse.append(s.charat(i)); return reverse.tostring();

Application state By Ajax the application state is stored by the client Refresh page problem Must backup the client state at the server side

Sessions HTTPServlet AbstractRemoteServiceServlet RemoteServiceServlet PozpatkuServiceImpl

Working with the session on the server public class PozpatkuServiceImpl extends RemoteServiceServlet implements PozpatkuService { public String pozpatku(string s) { StringBuffer reverse = new StringBuffer(s.length()); for (int i = (s.length() - 1); i >= 0; i--) { Set the session reverse.append(s.charat(i)); String toreturn = reverse.tostring(); // ulozim si posledni string do session getthreadlocalrequest().getsession().setattribute("laststring", toreturn); return toreturn; public String getlast() { return (String)getThreadLocalRequest().getSession().getAttribute("lastString"); Reading the

GWT and history in browser ProblEm: Ajax based application do not generate standard history in the browser Solution in GWT: iframe will store the history on command How it works: 1. We insert an iframe into HTML 2. Based on event X we actively record the history as a String 3. We react on event of transition in history by reading the strings, decoding the history and setting a new state.

Insert a frame to HTML iframe <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name='gwt:module' content='cz.cvut.fel.main=cz.cvut.fel.main'> <title>main</title> </head> <body> <script type="text/javascript" src="cz.cvut.fel.main/cz.cvut.fel.main.nocache.js"></script> <!-- include this if you want history support --> <iframe id=" gwt_historyframe" style="width:0;height:0;border:0"></iframe> </body> </html>

Write the history description to the record textbox.addvaluechangehandler(new ValueChangeHandler<String>() { public void onvaluechange(valuechangeevent<string> event) { History.newItem("text_" + event.getvalue()); );

Use the history description, set application state History.addValueChangeHandler(new ValueChangeHandler<String>() { public void onvaluechange(valuechangeevent<string> event) { String historytoken = event.getvalue(); // Parse the history token ); if (historytoken.substring(0, 5).equals("text_")) { String historystring = historytoken.substring(5, historytoken.length()); // Nastavime historickou hodnotu textbox.settext("history: "+historystring); else { textbox.settext("");

COMPILATION AND DEBUGGING

Debugging in Development mode

Speed Tracer Addon to Chrome!!! need for some historical version Similar in FF --enable-extension-timeline-api