vaadin 7 cn

110
Vaadin 7 Dr. Joonas Lehtinen 始人兼 CEO

Upload: jojule

Post on 25-May-2015

423 views

Category:

Technology


3 download

DESCRIPTION

My presentation about Vaadin 7.1 at JavaOne Shanghai on Jul 24, 2013. The slides are mostly in Chinese.

TRANSCRIPT

Page 1: Vaadin 7 CN

Vaadin7Dr. Joonas Lehtinen�始人兼 CEO

Page 2: Vaadin 7 CN

原始幻灯片位于slideshare.com/joonaslehtinen

Page 3: Vaadin 7 CN

Vaadin �介

new Label(“Hello world”)

Page 4: Vaadin 7 CN

版本 中的新特性7

Page 5: Vaadin 7 CN

入門

QA

Page 6: Vaadin 7 CN
Page 7: Vaadin 7 CN

用于富 web 用程序的用�界面框架

Page 8: Vaadin 7 CN

�建�

Page 9: Vaadin 7 CN

开人

提效

UX

Page 10: Vaadin 7 CN
Page 11: Vaadin 7 CN

htmljava

Page 12: Vaadin 7 CN

究竟�什么?

Page 13: Vaadin 7 CN
Page 14: Vaadin 7 CN

期望

Page 15: Vaadin 7 CN

��

Page 16: Vaadin 7 CN

��消�者“百万”用� “500”用�

>>100,000! / �� 5,000! / ��

10 个��1! / 用�

50 个��500! / 用�

Page 17: Vaadin 7 CN

挑�如何用��系��算�建消�者� UX

Page 18: Vaadin 7 CN

主要思路

Page 19: Vaadin 7 CN

123主要思路

Page 20: Vaadin 7 CN

1富�件

Page 21: Vaadin 7 CN

用�界面数据源主�

Page 25: Vaadin 7 CN

1.6 Going mobile

GWT is a versatile technology that allows developers to create application UI for desktop, tablet, and mobile consumption. As can be expected, over 98% of apps support desktop browsers, but we found it interesting that tablets had overtaken phones (at least when it came to support from GWT-based apps). In US, the number of apps supporting tablets was as high as 46%, while it was just 34% in Europe.

What kind of devices does your app support?

98.1%25.7%

Phones

36.1%

Tablets

Desktop browsers

Others

2.1%

“Since gwt is used extensively in the enterprise, this may explain why tablets are more popular than support for phones”

Daniel

Browsers developers expect to support in 2013

3.5 Browsers to support in 2012

IE 6/7 Safari Opera IE 8

6/7 8

14% 18% 36% 54%

Chrome

9 10IE 9 IE 10 Firefox

79% 80% 94% 94%Browsers developers expect to support in 2013

3.5 Browsers to support in 2012

IE 6/7 Safari Opera IE 8

6/7 8

14% 18% 36% 54%

Chrome

9 10IE 9 IE 10 Firefox

79% 80% 94% 94%

1.6 Going mobile

GWT is a versatile technology that allows developers to create application UI for

desktop, tablet, and mobile consumption. As can be expected, over 98% of apps

support desktop browsers, but we found it interesting that tablets had overtaken

phones (at least when it came to support from GWT-based apps). In US, the number

of apps supporting tablets was as high as 46%, while it was just 34% in Europe.

What kind of devices does your app support?

98.1%

25.7%

Phones

36.1%

Tablets

Desktop

browsers

Others2.1%

“Since gwt is used extensively

in the enterprise, this may

explain why tablets are more

popular than support for

phones”

Daniel

iPhoneAndroid

WP 8

1.6 Going mobile

GWT is a versatile technology that allows developers to create application UI for

desktop, tablet, and mobile consumption. As can be expected, over 98% of apps

support desktop browsers, but we found it interesting that tablets had overtaken

phones (at least when it came to support from GWT-based apps). In US, the number

of apps supporting tablets was as high as 46%, while it was just 34% in Europe.

What kind of devices does your app support?

98.1%

25.7%

Phones

36.1%

Tablets

Desktop

browsers

Others2.1%

“Since gwt is used extensively

in the enterprise, this may

explain why tablets are more

popular than support for

phones”

Daniel

iPadAndroidWindows 8

Page 26: Vaadin 7 CN

360 多个插件�件

Page 27: Vaadin 7 CN

用�界面数据源主�

Page 32: Vaadin 7 CN

用�界面数据源主�

Page 33: Vaadin 7 CN
Page 34: Vaadin 7 CN

InMemory, Bean, Method, Collection, JDBC, JPA, Hibernate, TextFile, FileSystem, Properties, EclipseLink, Lucene, Mockups, GAE, ...

Page 35: Vaadin 7 CN

2服�器 + 客�端

Page 36: Vaadin 7 CN

Web 用程序�

后端服�器

Web服�器 通信 JavaScript

Page 37: Vaadin 7 CN

Web 用程序�

必需 可� 可�必需 可�

Vaa

din

必需 可�必需

GW

T

必需必需JS

必需必需

必需 必需

JavaScriptJava 到

JavaScriptWeb服�器

后端服�器 通信

Page 38: Vaadin 7 CN

Web 用程序�

必需 可� 可�必需 可�

Vaa

din

必需 可�必需

GW

T

必需必需JS

必需必需

必需 必需

JavaScriptJava 到

JavaScriptWeb服�器

后端服�器 通信

1 �

3 �

代�行减少 50%

开工作量降低 50%

��工作量降低 50%

更容易学�

Page 39: Vaadin 7 CN

它到底是如何工作的?

Page 40: Vaadin 7 CN
Page 41: Vaadin 7 CN

• 初始 HTML• CSS(主�)• �片• JavaScript

共 1.2M

307k

��

135k

减少widgetset

Page 42: Vaadin 7 CN

• name=”Joonas”• ��按�

261 字�

Page 43: Vaadin 7 CN
Page 44: Vaadin 7 CN

• name=”Joonas”• ��按�

261 字�

• 添加通知

267 字�

Page 45: Vaadin 7 CN

Hello World!

Page 46: Vaadin 7 CN
Page 47: Vaadin 7 CN

https://github.com/vaadin/documentmanager

https://vaadin.com/learn

来源

如何制作截屏��

Page 48: Vaadin 7 CN

3利用 Java

Page 49: Vaadin 7 CN

JVM 上的任何�言

Page 50: Vaadin 7 CN

Internet ExplorerChromeFirefoxSafariOpera

iOSAndroid

Page 51: Vaadin 7 CN

没有 ��器 插件

不需要安装 任何�西

Page 52: Vaadin 7 CN

Servlet Portlet

(大多数)云

Page 53: Vaadin 7 CN

EclipseIntelliJ IDEA

NetbeansMaven

Ant∙ ∙ ∙

Page 54: Vaadin 7 CN

Vaadin7.1

Page 55: Vaadin 7 CN

v32002

v0.12001

开源

Page 56: Vaadin 7 CN

v42006

Ajax

v52007

Page 57: Vaadin 7 CN

7二月v6

2009

Page 58: Vaadin 7 CN

934 tickets closed during 16 months of development

3939 commits made by 23 authors

Oldest ticket created 3/2008Newest ticket 2/2013

3939 commits made by 23 authors93 % by 6 persons

> 1 000 000 lines of code touched

Page 59: Vaadin 7 CN

完整的体系

脱胎 骨Sass

JS

HTML5+=GWT

RPC状

UI

字段

推送

Page 60: Vaadin 7 CN
Page 61: Vaadin 7 CN
Page 62: Vaadin 7 CN
Page 63: Vaadin 7 CN
Page 64: Vaadin 7 CN
Page 65: Vaadin 7 CN
Page 66: Vaadin 7 CN
Page 67: Vaadin 7 CN
Page 68: Vaadin 7 CN
Page 70: Vaadin 7 CN

收藏精� 7.1

Page 71: Vaadin 7 CN

Vaadin += GWT

Page 72: Vaadin 7 CN
Page 73: Vaadin 7 CN
Page 74: Vaadin 7 CN
Page 75: Vaadin 7 CN

GWT兼容

Page 76: Vaadin 7 CN

服�器-

客�-

端�生�力而

�化�控制而 �化

Page 77: Vaadin 7 CN

服�器-客�

-

端�生�力而 �化

�控制而

�化

Page 78: Vaadin 7 CN

架�

Page 79: Vaadin 7 CN
Page 80: Vaadin 7 CN

Sass�法超�的�式表

演示

Page 81: Vaadin 7 CN

重新��的表�

Page 82: Vaadin 7 CN

public class Employee { String firstName; String lastName; double salary; Date birthDate; // Getters, setters, …}

Form form = new Form();form.setItemDataSource( new BeanItem<Employee>(employee));

6

Page 83: Vaadin 7 CN
Page 84: Vaadin 7 CN
Page 85: Vaadin 7 CN

form.setFormFieldFactory(new FormFieldFactory() {

public Field createField(Item item, Object propertyId, Component uiContext) {

if ("birthDate".equals(propertyId)) { DateField df = new DateField(); df.setResolution(DateField.RESOLUTION_DAY); return df; }

// ..

return DefaultFieldFactory.createFieldByPropertyType(item .getItemProperty(propertyId).getType()); } });

6

Page 86: Vaadin 7 CN

GridLayout form = new GridLayout(2,2) {

TextField firstName = new TextField("First name"); TextField lastName = new TextField("Last name"); TextField salary = new TextField("Salary"); DateField birthDate = new DateField("Birth date");

{ birthDate.setResolution(Resolution.DAY); setSpacing(true); addComponent(firstName); addComponent(lastName); addComponent(birthDate); addComponent(salary); } };

BeanFieldGroup<Employee> fieldGroup = new BeanFieldGroup<Employee>(Employee.class); fieldGroup.bindMemberFields(form); fieldGroup.setItemDataSource(new BeanItem<Employee>(employee));

7

Page 87: Vaadin 7 CN

public class Person {

@Size(min = 5, max = 50) private String name;

@Min(0) @Max(100) private int age;

// + constructor + setters + getters}

Page 88: Vaadin 7 CN

模型�

表示�

“Joonas Lehtinen”

Component

firstName = “Joonas”lastName = “Lehtinen”

演示

Page 89: Vaadin 7 CN

RPC状

Page 90: Vaadin 7 CN

Component

Widget

Paintable

服�器

客�端Variable

Changes

UIDL

6

Page 91: Vaadin 7 CN

Component

Widget

Connector

RPC

7State

演示

服�器

客�端

Page 92: Vaadin 7 CN

public interface ButtonRpc extends ServerRpc { public void click(MouseEventDetails details);}

private ButtonRpc rpc = RpcProxy.create(ButtonRpc.class, this);

public void onClick(ClickEvent event) { rpc.click( new MouseEventDetails(event));}

服�器客�端

private ButtonRpc rpc = new ButtonRpc() { public void click( MouseEventDetails details) { // do stuff }};

public Button() { registerRpc(rpc);}

演示

Page 93: Vaadin 7 CN

JavaScript插件

Page 94: Vaadin 7 CN

getPage().getJavaScript().addFunction("myCallback", new JavaScriptCallback() { public void call(JSONArray arguments) throws JSONException { // Do something with the arguments } });

用 Java �布 API

window.myCallback('foo', 100);

在 JavaScript 中使用

Page 95: Vaadin 7 CN

public class MyWidget extends AbstractJavaScriptComponent { public MyWidget() { addFunction("plotClick", new JavaScriptFunction() { public void call(JSONArray arguments) throws JSONException { // Do something with the event } }); }

public static class MyWidgetState extends JavaScriptComponentState { public List<List<List<Double>>> plotSeriesData = new ArrayList<List<List<Double>>>(); } public MyWidgetState getState() { return (MyWidgetState) super.getState(); }

}

用于 Widget 的服�器端 Java API

Page 96: Vaadin 7 CN

window.com_example_MyWidget = function() { var element = $(this.getWidgetElement());

// Draw a plot for any server-side (plot data) state change this.onStateChange = function() { $.plot(element, this.getState().series, {grid: {clickable: true}}); }

// Communicate local events back to server-side component element.bind('plotclick', function(event, point, item) { if (item) {

var onPlotClick = this.getCallback("plotClick"); onPlotClick(item.seriesIndex, item.dataIndex); } });}

用于 Widget 的服�器端 Java API

Page 97: Vaadin 7 CN

服�器推送

Page 98: Vaadin 7 CN

@Push MyUI

async-supported = true

vaadin-push dependency

Page 99: Vaadin 7 CN

入門

Page 100: Vaadin 7 CN

入門

Page 101: Vaadin 7 CN
Page 102: Vaadin 7 CN

Eclipse

Page 103: Vaadin 7 CN

mvn archetype:generate \-DarchetypeGroupId=com.vaadin \-DarchetypeArtifactId=vaadin-archetype-application \-DarchetypeVersion=7.1.0

Page 104: Vaadin 7 CN

迁移指南:从 Vaadin 6 到 7

https://vaadin.com/wiki/-/wiki/Main/Migrating+from+Vaadin+6+to+Vaadin+7

Page 105: Vaadin 7 CN

免�下�vaadin.com/book

728 �

9 789529 319701

ISBN 978-952-93-1970-1

PDF, ePub, HTML

Page 106: Vaadin 7 CN

免�下�vaadin.com/refcard

8 �PDF

Get

Mor

e R

efca

rdz!

Vis

it r

efca

rdz.

com

#85

Vaa

din

7: A

New

Way

to

Bui

ld W

eb U

Is w

ith

Java

By: Marko Grönroos

Vaadin is a web application development framework that allows you

to build web applications much as you would with traditional desktop

frameworks, such as AWT or Swing. A UI is built hierarchically from user

interface components contained in layout components. User interaction is

handled in an event-driven manner.Vaadin supports both a server-side and a client-side development model.

In the server-side model, the application code runs on a server, while the

actual user interaction is handled by a client-side engine that runs in the

browser. The client-server communications and client-side technologies,

such as HTML and JavaScript, are invisible to the developer. The client-

side engine runs as JavaScript in the browser, so there is no need to install

plug-ins.

Figure 1: Vaadin Client-Server Architecture

The client-side development model allows building new client-side widgets

and user interfaces with the GWT toolkit included in Vaadin. The widgets

can be integrated with server-side component counterparts to enable

using them in server-side applications. You can also make pure client-side

UIs, which can communicate with a back-end service.A server-side Vaadin application consists of one or more UI classes that

extend the com.vaadin.UI class and implement the init() method.

@Title(“My Vaadin UI”)

public class HelloWorld extends com.vaadin.UI {

@Override protected void init(VaadinRequest request) {

// Create the content root layout for the UI

VerticalLayout content = new VerticalLayout();

setContent(content); // Display the greeting

content.addComponent(new Label(“Hello World!”));

}}

Normally, you need to:� extend the UI class� build an initial UI from components

� GHQH�HYHQW�OLVWHQHUV�WR�LPSOHPHQW

Optionally, you can also:� set a custom theme for the UI

� bind components to data

� bind components to resources

Figure 2: Architecture for Vaadin Applications

You can create a Vaadin application project easily with the Vaadin Plugin

for Eclipse, with NetBeans, or with Maven.HotTip

You can get a reference to the UI object associated

with the currently processed request from anywhere in

the application logic with UI.getCurrent(). You can also

access the current VaadinSession, VaadinService, and

VaadinServlet objects in the same way.

CONTENTS INCLUDE:k�Creating a Server-side UI

k�Componentsk�Themesk�Class Diagramk�Data Bindingk�Widget Integration... and more!

Vaadin 7: Modern Web Apps in Java

Vaadin ChartsThe best charting component for Vaadin

with over 50 chart types.Learn more

ABOUT VAADIN

CREATING A SERVER-SIDE UI

Brought to you by:

Page 107: Vaadin 7 CN

免�下�vaadin.com/refcard

8 �PDF

Get

Mor

e R

efca

rdz!

Vis

it r

efca

rdz.

com

#85

Vaa

din

7: A

New

Way

to

Bui

ld W

eb U

Is w

ith

Java

By: Marko Grönroos

Vaadin is a web application development framework that allows you

to build web applications much as you would with traditional desktop

frameworks, such as AWT or Swing. A UI is built hierarchically from user

interface components contained in layout components. User interaction is

handled in an event-driven manner.Vaadin supports both a server-side and a client-side development model.

In the server-side model, the application code runs on a server, while the

actual user interaction is handled by a client-side engine that runs in the

browser. The client-server communications and client-side technologies,

such as HTML and JavaScript, are invisible to the developer. The client-

side engine runs as JavaScript in the browser, so there is no need to install

plug-ins.

Figure 1: Vaadin Client-Server Architecture

The client-side development model allows building new client-side widgets

and user interfaces with the GWT toolkit included in Vaadin. The widgets

can be integrated with server-side component counterparts to enable

using them in server-side applications. You can also make pure client-side

UIs, which can communicate with a back-end service.A server-side Vaadin application consists of one or more UI classes that

extend the com.vaadin.UI class and implement the init() method.

@Title(“My Vaadin UI”)

public class HelloWorld extends com.vaadin.UI {

@Override protected void init(VaadinRequest request) {

// Create the content root layout for the UI

VerticalLayout content = new VerticalLayout();

setContent(content); // Display the greeting

content.addComponent(new Label(“Hello World!”));

}}

Normally, you need to:� extend the UI class� build an initial UI from components

� GHQH�HYHQW�OLVWHQHUV�WR�LPSOHPHQW

Optionally, you can also:� set a custom theme for the UI

� bind components to data

� bind components to resources

Figure 2: Architecture for Vaadin Applications

You can create a Vaadin application project easily with the Vaadin Plugin

for Eclipse, with NetBeans, or with Maven.HotTip

You can get a reference to the UI object associated

with the currently processed request from anywhere in

the application logic with UI.getCurrent(). You can also

access the current VaadinSession, VaadinService, and

VaadinServlet objects in the same way.

CONTENTS INCLUDE:k�Creating a Server-side UI

k�Componentsk�Themesk�Class Diagramk�Data Bindingk�Widget Integration... and more!

Vaadin 7: Modern Web Apps in Java

Vaadin ChartsThe best charting component for Vaadin

with over 50 chart types.Learn more

ABOUT VAADIN

CREATING A SERVER-SIDE UI

Brought to you by:

Page 108: Vaadin 7 CN

Apache�可

Page 109: Vaadin 7 CN

社区内活�着

100.000多 名开�人�

Page 110: Vaadin 7 CN

? [email protected] vaadin.com/joonas

@joonaslehtinen

vaadin.com/forumvaadin.com/pro (support)

slideshare.com/joonaslehtinen