• 検索結果がありません。

勉強会 資料 Google Developer Group 京都

N/A
N/A
Protected

Academic year: 2018

シェア "勉強会 資料 Google Developer Group 京都"

Copied!
45
0
0

読み込み中.... (全文を見る)

全文

(1)

GWT 入門

2.0

越智洋司 京都 GTUG

1 回 Google Web Toolkit 勉強会 in 京都 (#gwt_kyoto)

(2)

く自己紹

□ 某私立大学教員 理工系

□ 昨冬 Google Wave Hackathon 初参

新入

e-Learning 研究開 専門

最新 技術動向 関心あ

基曓的 ン 好

実践的 あ いうわけ あ

□ い 効率良く 開 進 いく ? 学生指導含

→ GWT 半年ほ

(3)

曓日 話 内容

多少 私 思い違い 偏見? あ

適時突

前半: GWT 入門編 担当:越智

GWT 概要

GWT RPC

UIBinder

後半:実装編 担当:白山

記 使 実装 体験 う

白山 急遽 席 越智& ッ 対応

(4)

GWT

□昨 ン開 ン

志向 時代

JavaScript 処理

□ 側 動作 AJAX ン ン Java

記述 最適 JavaScript

Java JavaScript

(5)

GWT 標準

標準的 GUI 部品 対応

WidgetList

http://code.google.com/intl/ja/webtoolkit/doc/latest/RefWidgetGallery.html

(6)

GWT 使う

□ 側 ン 側

Java

○言語 教え 手間 省け

JavaScript 嫌い 苦手 Java 救世主!

JavaScript 大変

○言語 様 貧弱

○開 環境 曑整備

GWT 利用

Java 言語 様や開 環境 利用

(7)

GWT 使う

□ 間 互換性問題 い GWT 解決

Chrome, Internet Explorer, Firefox, and Safari…etc

主要 対応 JavaScript 自動変換

JavaScript 用意 必要 い

(8)

GWT 使

私 研究 場合

○研究 主 Java 中心

○講義 & Java 関係一 習わ

△ 状態 い 教え ?

→ ワ 絶え 模索 日々

JSF 資料少

JavaScript 作 ッ !

半年前 GWT 出会い

年生 わ 数 月 作

(9)

Web 時代

HTML JavaScript 事実 言語

JavaAppletFlash 実装 終焉

JavaScript 困難 GWT

最高 ン!!

JavaScript Web

Java GWT

(10)

代表的 JavaIDE GWT 対応

Google Plugin for Eclipse

Eclipse

GWT SDK

Eclipse

違う点 注意

Netbeans

GWT4NB いう

(11)

GWT 特徴 探

GWT 構造 ~

ン 側

両 呼び出

(12)

設定 簡単 明

XXXX.gwt.xml

<!-- Other module inherits -->

<inherits name=“○ ○ ○ ○ ○ ○ ○ ○ ○ ○”>

<!-- Specify the app entry point class. -->

<entry-point class='org.ochilab.client.TestGWT'/>

<!-- Specify the paths for translatable code -->

<source path='client'/>

<source path='shared'/>

•Entry-point 指定:最初 起動

利用 < inherits > 指定

(13)

GWT 特徴 探

GWT 構造 ~

呼び出 元 HTML 必要

<script type="text/javascript" language="javascript" src="testgwt/testgwt.nocache.js"></script>

GWT 導く javaScript 記述

(14)

GWT 特徴 探

HTML 関係~

GWT HTML 要素 Java 書く

いうわけ あ

HTML Java記述

HTML要素 対 ッ 組 込

(15)

GWT 特徴 探

~ ン 実行例~

Eclipse 実行 画面

(16)

GWT 特徴 探

HTML 関係~

<h1>Web Application Starter Project</h1>

<table align="center">

<tr>

<td colspan="2" style="font-weight:bold;">Please enter your name:</td>

</tr>

<tr>

<td id="nameFieldContainer"></td>

<td id="sendButtonContainer"></td>

</tr>

<tr>

<td colspan="2" style="color:red;" id="errorLabelContainer"></td>

</tr>

</table>

(17)

public class TestGWT implements EntryPoint { public void onModuleLoad() {

final Button sendButton = new Button(" "); final TextBox nameField = new TextBox();

nameField.setText("日曓語 OK"); final Label errorLabel = new Label(); // We can add style names to widgets

sendButton.addStyleName("sendButton");

// Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); }

利用可能

(18)

GWT 特徴 探

css 関係~

<link type="text/css" rel="stylesheet" href="TestGWT.css">

.sendButton { display: block; font-size: 16pt; }

.gwt-DialogBox { width: 400px; }

TestGWT.css

sendButton.addStyleName("sendButton");

GWT Widget

指定あ

// Create the popup dialog box

final DialogBox dialogBox = new DialogBox();

(19)

補足: ン 記述 ッ

HTML

<body> 直接追

<body>

</body>

RootPanel.get().add(nameField);

含 全 Java 書く 可能

(20)

気 け い いけ い

Java

Servlet Strut JSF

→ 移 意識 設計

Ajax

→ 原則 移 状態 管理 必要

GWT 履歴管理機能 用意

(21)

履歴機能

古い ン 使わ い

HistoryLister 実装 非奨励 注意!

•ValueChangeHandler 実装

•History

http://127.0.0.1:8888/UserControl.html?gwt.codesvr=127.0.0.1:9997#start

URL 曒尾 追記 状態 区別可能

戻 ン 対応

書い け 戻 わけ い点 注意

(22)

JSNI JavaScript 連携

JSNI JavaScript Native Interface

protected native void xxxxxx() /*-{

ここにJavaScriptを書く }-*/;

GWT 曑対応 JavaScript 扱え

Java 記述部 JavaScript 部 授受 可能

(23)

JSNI 威力

昨年 月 GoogleWaveHackathon

優勝 村

ン ッ ン

GWT HTML5 Canvas 利用

JSNI 使 GWT 曑対応部 補完

(24)

GWT RPC

Ajax

→ 非 期通信

GWT GWT-RPC いう 実現

ン 側 側

xxxx()

}

xxxx()

(25)

GWT-RPC 必要

□ ッ 実装 側

ッ 実装

□ 定義 ン 用

□ 定義 ン ン 用

ッ 定義

注意事項: ン 関連性 前 対応

(26)

ン 関係

<<interface>> GreetingService

<<interface>> GreetingServiceAsync

GreetingServiceImpl Client

ッ 実装 定義 ン

用 定義 ン

ン 用

呼び出

(27)

GWT-RPC client

定義 ン 用

定義 ン ン 用

GreetingService.java

@RemoteServiceRelativePath("greet")

public interface GreetingService extends RemoteService {

String greetServer(String name) throws IllegalArgumentException; }

GreetingServiceAsync.java public interface GreetingServiceAsync {

void greetServer(String input, AsyncCallback<String> callback) throws IllegalArgumentException;

}

(28)

GWT-RPC sever

@SuppressWarnings("serial")

public class GreetingServiceImpl

extends RemoteServiceServlet implements GreetingService { public String greetServer(String input)

throws IllegalArgumentException { }

}

(29)

ン 呼び出

private final GreetingServiceAsync greetingService

= GWT.create(GreetingService.class);

greetingService.greetServer(textToServer,new AsyncCallback<String>() { public void onFailure(Throwable caught) {

処理 失敗 場合 記述

}

public void onSuccess(String result) {

処理 成 場合 記述

} });

(30)

GWT-RPC :転送

GWT RPC 転送

char,byte,short,int,long,boolean,float,double

ッ 類

Char,Byte,Short,Int,Long,Boolean,Float,Double,String,Date

配列 一部 ン

a ,Ha a ac , ec , … e c

定義

(31)

GWT-RPC 定義

public class testObj implements Serializable{

ン 変数

getter setter }

Serializable 実装

ン 変数 様 制約

client shared

(32)

GWT2.0 新機能

~ DevelopmentMode

GWT

→ ッ 時間 JavaJavaScript 変換

Google Web Toolkit Developer Plugin

一般 実行可能

曑対応 あ ?

以前 HostedMode 用意 い

Java 変換

Hosted 確認

ッ 容易

(33)

GWT2.0 新機能

~ LayoutPanel 拡張~

http://code.google.com/intl/ja/webtoolkit/doc/latest/DevGuideUiPanels.html

•TabLayoutPanel

•StackLayoutPanel

•DockLayoutPanel

…..etc

表現 豊富

(34)

GWT2.0 新機能

UIBinder

Widget 記述 定義

Java

Widget 生成 記述 不要

○ ン 定義 簡素

ン 削減

定義 ui.xml

(35)

最新 Eclipse ン 対応

Widget

(36)

UI Binder

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">

<ui:style> .important {

font-weight: bold; }

</ui:style>

<g:HTMLPanel> Hello,

<g:Button styleName="{style.important}" ui:field= "button" />

</g:HTMLPanel>

</ui:UiBinder>

(37)

public class uitest extends Composite {

private static uitestUiBinder uiBinder = GWT.create(uitestUiBinder.class); interface uitestUiBinder extends UiBinder<Widget, uitest> {

}

@UiField

Button button;

public uitest(String firstName) {

initWidget(uiBinder.createAndBindUi(this)); button.setText(firstName);

}

@UiHandler("button")

void onClick(ClickEvent e) { Window.alert("Hello!"); }

}

ン 記述

ン 記述

自体 Widget

(38)

ン 割 当

uitest ut = new uitest(“ "); RootPanel.get().add(ut);

普通 Widget 利用 感覚

(39)

ui.xml Java 関連付け

2 方法

e a e . . 指定

Interface 定義 直前 記述

○○ .ui.xml ○○ .java

(40)

XML 記述 定義 詳細

Eclipse 教え ^^

GWT-Widget JavaDoc 詳細

(41)

XML 属性 設定

UiBinder Attribute Setter

UiBinder Xml 属性 Widget Setter 指定

例え Widget setTitle いう属性 あ 場合

<g:Label title=" "> </g:Label>

<g:HorizontalPanel>

<g:cell horizontalAlignment="ALIGN_RIGHT“

verticalAlignment="ALIGN_BOTTOM">

</g:cell> </g:HorizontalPanel>

(42)

ン 処理 い

public class MyFoo extends Composite {

@UiField Button button; public MyFoo() {

initWidget(button); }

@UiHandler("button")

void handleClick(ClickEvent e) { Window.alert("Hello, AJAX"); }

}

ン 記述 け ッ

(43)

UIBinder 個人的 感想

HTML+JavaScript GWT 使い

UIBinder HTML XML 書く

矛盾 い ?

否!

Java 記述 簡素

xml 意外 書 や い HTML 両立 いい

(44)

前半

GWT 基曓的

GWT2.0 新機能 い 一部

後半

実際 作 う!

(45)

謝辞

○曓勉強会 京都 株式会社様

会場提供 開催

○曓資料作成 京都 GTUG

様々 助言 い

○曓勉強会 準備 運営 京都 GTUG ッ 方々

協力 あ

あ う い

参照

関連したドキュメント

onsemi is notifying customers of its use of 0.8 mils Pd-coated Cu wire for JFETs devices assembled in SOT-23 at onsemi Leshan, China facility. The change requires wafer top

In case of any differences between the English and Japanese version, the English version shall

Title of Change: D2PAK single reel packing box change(include dry packing)&amp;remove sponge pad fill for dry packing for D2PAK/DPAK &amp; SPM5 &amp; Remove 1ea bubble bag

In case of any differences between the English and Japanese version, the English version shall

Title of Change: SOIC-8 Insourcing to ON Semiconductor Philippines (OSPI) Factory from GEM (China) Proposed first ship date: Not Applicable.. Contact information: Contact

最終的な認定データおよび特性データは最終製品 / プロセス変更通知 (FPCN) に含まれます。この IPCN は、変 更実施から少なくとも 90

This Product Change Notification is intended to informed the customer that the Wettable Flank leadframe design and plating process are being enhanced, as tabulated below, in order

The completed qualification and characterization data will be included in the Final Product/Process Change