- 浏览: 111192 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
0c0c0f:
原来如此str.replaceAll("[\\x00 ...
xml中的非法字符 -
twlkyao:
谢谢,问题解决了。
xxx is not in the sudoers file解决方法 -
guanshubang:
czxvxcv[b][/b]
在eclipse中使用junit -
帅先勃:
...
Java设计模式之生产者消费者模式 -
liberD:
我昨天试了,报了很多的错误。请问,您遇到这种情况了吗?
git安装
GreetingResponsePresenter.java
01.
package
co.uk.hivedevelopment.greet.client.mvp;
02.
import
net.customware.gwt.presenter.client.EventBus;
03.
import
net.customware.gwt.presenter.client.place.Place;
04.
import
net.customware.gwt.presenter.client.place.PlaceRequest;
05.
import
net.customware.gwt.presenter.client.widget.WidgetDisplay;
06.
import
net.customware.gwt.presenter.client.widget.WidgetPresenter;
07.
import
co.uk.hivedevelopment.greet.shared.event.GreetingSentEvent;
08.
import
co.uk.hivedevelopment.greet.shared.event.GreetingSentEventHandler;
09.
import
com.allen_sauer.gwt.log.client.Log;
10.
import
com.google.gwt.event.dom.client.ClickEvent;
11.
import
com.google.gwt.event.dom.client.ClickHandler;
12.
import
com.google.gwt.event.dom.client.HasClickHandlers;
13.
import
com.google.gwt.user.client.ui.DialogBox;
14.
import
com.google.gwt.user.client.ui.HasHTML;
15.
import
com.google.gwt.user.client.ui.HasText;
16.
import
com.google.inject.Inject;
17.
public
class
GreetingResponsePresenter
extends
WidgetPresenter {
18.
public
interface
Display
extends
WidgetDisplay {
19.
HasText getTextToServer();
20.
HasHTML getServerResponse();
21.
HasClickHandlers getClose();
22.
DialogBox getDialogBox();
23.
}
24.
public
static
final
Place PLACE =
new
Place(
"GreetingResponse"
);
25.
@Inject
26.
public
GreetingResponsePresenter(
final
Display display,
final
EventBus eventBus) {
27.
super
(display, eventBus);
28.
bind();
29.
}
30.
31.
@Override
32.
protected
void
onBind() {
33.
// Add a handler to close the DialogBox
34.
display.getClose().addClickHandler(
new
ClickHandler() {
35.
public
void
onClick(
final
ClickEvent event) {
36.
display.getDialogBox().hide();
37.
// Not sure of a nice place to put these!
38.
// sendButton.setEnabled(true);
39.
// sendButton.setFocus(true);
40.
}
41.
});
42.
eventBus.addHandler(GreetingSentEvent.TYPE,
new
GreetingSentEventHandler() {
43.
@Override
44.
public
void
onGreetingSent(
final
GreetingSentEvent event) {
45.
Log.info(
"Handling GreetingSent event"
);
46.
47.
display.getTextToServer().setText(event.getName());
48.
display.getServerResponse().setHTML(event.getMessage());
49.
display.getDialogBox().show();
50.
}
51.
});
52.
}
53.
@Override
54.
protected
void
onUnbind() {
55.
// Add unbind functionality here for more complex presenters.
56.
}
57.
public
void
refreshDisplay() {
58.
// This is called when the presenter should pull the latest data
59.
// from the server, etc. In this case, there is nothing to do.
60.
}
61.
public
void
revealDisplay() {
62.
// Nothing to do. This is more useful in UI which may be buried
63.
// in a tab bar, tree, etc.
64.
}
65.
/**
66.
* Returning a place will allow this presenter to automatically trigger when
67.
* '#GreetingResponse' is passed into the browser URL.
68.
*/
69.
@Override
70.
public
Place getPlace() {
71.
return
PLACE;
72.
}
73.
@Override
74.
protected
void
onPlaceRequest(
final
PlaceRequest request) {
75.
// this is a popup
76.
}
77.
}
At this point, we're still missing some code but hopefully you should start to see the structure coming together.
Events
Since this is a simple application, we only have one event - the GreetingSent event which has a corresponding handler:
GreetingSent.java
01.
package
co.uk.hivedevelopment.greet.shared.event;
02.
import
com.google.gwt.event.shared.GwtEvent;
03.
public
class
GreetingSentEvent
extends
GwtEvent{
04.
public
static
Type TYPE =
new
Type();
05.
06.
private
final
String name;
07.
private
final
String message;
08.
09.
public
GreetingSentEvent(
final
String name,
final
String message) {
10.
this
.name = name;
11.
this
.message = message;
12.
}
13.
14.
public
String getName() {
15.
return
name;
16.
}
17.
18.
public
String getMessage() {
19.
return
message;
20.
}
21.
22.
@Override
23.
public
Type getAssociatedType() {
24.
return
TYPE;
25.
}
26.
@Override
27.
protected
void
dispatch(
final
GreetingSentEventHandler handler) {
28.
handler.onGreetingSent(
this
);
29.
}
30.
}
GreetingSentHandler.java
1.
package
co.uk.hivedevelopment.greet.shared.event;
2.
import
com.google.gwt.event.shared.EventHandler;
3.
public
interface
GreetingSentEventHandler
extends
EventHandler {
4.
void
onGreetingSent(GreetingSentEvent event);
5.
}
If you now look at the project references for the event and handler you can see where the events are fired and subsequently handled. The components are blissfully unaware of what produced the event and it just has the information that it needs to get the job done. Now imagine if you want to have another component that also reacts to this event, say to update another part of the GUI. Simple, just register another event handler - no spaghetti code.
RPC
Let's define client RPC. As mentioned earlier, we'll not be making the RPC calls directly. Instead we'll use the command pattern and let the gwt-dispatch library handle the underlying server calls. Although this is an implementation of the command pattern, it turns out that there is already a core GWT class called Command, so the authors of the gwt-dispatch library have opted to use Action instead - so "actions" are really "commands".
In our example, we'll define the Action SendGreeting which represent our server request and a SendGreetingResult class to encapsulate the server response:
SendGreeting.java
01.
package
co.uk.hivedevelopment.greet.shared.rpc;
02.
import
net.customware.gwt.dispatch.shared.Action;
03.
public
class
SendGreeting
implements
Action {
04.
private
static
final
long
serialVersionUID = 5804421607858017477L;
05.
private
String name;
06.
@SuppressWarnings
(
"unused"
)
07.
private
SendGreeting() {
08.
}
09.
public
SendGreeting(
final
String name) {
10.
this
.name = name;
11.
}
12.
public
String getName() {
13.
return
name;
14.
}
15.
}
SendGreetingResult.java
01.
package
co.uk.hivedevelopment.greet.shared.rpc;
02.
import
net.customware.gwt.dispatch.shared.Result;
03.
public
class
SendGreetingResult
implements
Result {
04.
private
static
final
long
serialVersionUID = 7917449246674223581L;
05.
private
String name;
06.
private
String message;
07.
public
SendGreetingResult(
final
String name,
final
String message) {
08.
this
.name = name;
09.
this
.message = message;
10.
}
11.
@SuppressWarnings
(
"unused"
)
12.
private
SendGreetingResult() {
13.
}
14.
public
String getName() {
15.
return
name;
16.
}
17.
public
String getMessage() {
18.
return
message;
19.
}
20.
}
发表评论
-
git安装
2011-07-05 17:39 1972linux 安装git 2011-01-06 10:01 ... -
myeclipse8.0GA CDkey
2010-05-24 13:33 1198Subscriber:MaYong Subscript ... -
svn无法更新,问题解决方法
2010-03-29 10:23 11202Working copy’**’locked. Please ... -
xml中的非法字符
2010-03-10 18:06 13927今使用Jdom生成xml文件的时候,总是出现0x0,0x8为非 ... -
mysql 添加访问权限
2010-03-10 15:11 1609记录下来,省得以后找不到。 shell>mysq ... -
xxx is not in the sudoers file解决方法
2010-01-11 11:19 5097用sudo时提示"xxx is not in t ... -
Session ID and Cookie
2010-01-08 14:59 3230具体来说cookie机制采用 ... -
Google Web Toolkit (GWT) MVP Example (5)
2009-11-24 18:13 1622LogProvider.java view sou ... -
Google Web Toolkit (GWT) MVP Example (4)
2009-11-24 18:10 1966At this point, the client code ... -
Google Web Toolkit (GWT) MVP Example (2)
2009-11-24 18:03 2532GreetingPresenter.java vi ... -
Google Web Toolkit (GWT) MVP Example (1)
2009-11-24 17:49 3833本文转自:http://blog.hivedevelopmen ... -
Guice了解理解及应用
2009-11-20 11:39 1204首先,从dependency injection理解开始,咱不 ...
相关推荐
Google Web Toolkit(GWT)是一个用于开发和优化复杂浏览器端应用的开源工具集,它允许开发者使用Java语言编写前端代码,然后通过编译器将Java代码转换成兼容各主流浏览器的JavaScript、HTML和CSS。《Google Web工具...
Google Web Toolkit(GWT)是Google推出的一款强大的Web开发框架,专注于帮助开发者使用Java语言创建高性能、跨浏览器的Web应用程序。GWT g-2.10.0是该框架的一个重要版本更新,提供了许多增强的功能和优化,以提升...
GWT(Google Web Toolkit) 是 Google 最近推出的一个开发 Ajax 应用的框架,它支持用 Java 开发和调试 Ajax 应用,本文主要介绍如何利用 GWT 进行 Ajax 的开发。 GWT特性简介 1.动态,可重用的UI组件 GWT提供的...
Google Web Toolkit(GWT)是Google推出的一款开源的、基于Java的Web开发框架,它允许开发者使用Java语言来编写前端应用程序。GWT-2.8.2是该SDK的一个版本,提供了最新的特性和改进,旨在简化Web应用的开发流程,...
### Google Web Toolkit (GWT) 入门指南 #### 一、引言 随着网络技术的发展,用户对Web应用的期望越来越高,不仅要求其功能强大,还希望具有良好的交互性和用户体验。为此,一种名为Ajax(Asynchronous JavaScript...
《Google Web Toolkit Applications》这本书是针对Google Web Toolkit(GWT)这一强大开发工具的深入指南。GWT是一款由Google开发的开源JavaScript框架,它允许开发者使用Java语言来编写Web应用程序,然后自动编译成...
### Google Web Toolkit (GWT) 开发 Ajax 技术详解 #### 一、GWT特性简介 **GWT**(Google Web Toolkit)是Google推出的一款用于构建和优化复杂Web前端应用的开发工具包。它通过提供一系列强大的特性,极大地简化...
在"ajax例子,Google Web Toolkit 1.0.21-ajax example"中,我们可以预期找到的是一个使用GWT 1.0.21构建的Ajax示例应用。这个示例可能展示了如何使用GWT库创建异步通信,以及如何处理服务器返回的数据。通过学习这个...
### 使用Google Web Toolkit (GWT) 开发基于AJAX的SAP NetWeaver J2EE框架Web应用 #### 概述 本文档旨在提供一种利用Google Web Toolkit (GWT) 在SAP NetWeaver J2EE框架下开发AJAX基础Web应用的方法。SAP ...
谷歌Web工具包(Google Web Toolkit,简称GWT)是一种开源的Java框架,它允许开发者使用Java语言编写客户端的Web应用程序,然后自动编译为优化过的JavaScript代码。GWT的核心理念是利用Java的强类型、面向对象的特性...
Google Web Toolkit(GWT)是主要工具,它允许开发者使用 Java 语言来编写前端的 AJAX 应用程序。Ajax,即异步 JavaScript 和 XML,是一种用于创建快速互动网页的技术。通过 GWT,Java 开发者无需深入学习 ...
### Google Web Toolkit (GWT):工作原理与应用实例 #### 一、GWT简介 Google Web Toolkit(GWT)是一种强大的开发框架,用于构建基于AJAX的Web应用程序。GWT的主要特点在于它允许开发者完全使用Java语言进行前端...
Google Web Toolkit(GWT)是Google推出的一款开源的JavaScript开发框架,它允许开发者使用Java语言来编写前端Web应用。GWT API文档是开发者理解和使用GWT进行开发的重要参考资料,提供了全面的技术指南和API参考。 ...
Google Web Toolkit(GWT)1.5.3是一款由Google开发的开源JavaScript开发框架,它允许Java开发者使用Java语言来构建高性能、跨浏览器的Web应用程序。这个版本是GWT的一个重要里程碑,带来了许多改进和新特性,使得...
《加速GWT:构建企业级Google Web Toolkit应用》是一本深度探讨如何利用Google Web Toolkit(GWT)构建高性能Ajax应用程序的专业书籍。本书作者Vipul Gupta深入解析了GWT的核心功能,以及如何通过GWT生成优化的...
Google Web Toolkit(GWT)是一款由Google推出的开源框架,专为Java开发者设计,旨在简化和加速Web应用程序的开发过程。它允许开发者使用Java语言编写前端代码,并将其编译成高性能的JavaScript,从而在浏览器上运行...
**Java开发人员的Ajax:Google Web Toolkit (GWT) 入门** Google Web Toolkit (GWT) 是一个强大的工具,它允许Java开发人员使用熟悉的Java语言来构建高性能、跨浏览器的Ajax应用程序。GWT通过将Java代码编译为优化...
**GWT (Google Web Toolkit)** 是一款由Google开发的开源工具包,专为Java开发者设计,使得他们能够使用Java语言创建高效、动态且交互性强的Ajax应用。GWT通过将Java代码编译成浏览器可执行的JavaScript和HTML,解决...
Google Web Toolkit(GWT)