- 浏览: 111189 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
0c0c0f:
原来如此str.replaceAll("[\\x00 ...
xml中的非法字符 -
twlkyao:
谢谢,问题解决了。
xxx is not in the sudoers file解决方法 -
guanshubang:
czxvxcv[b][/b]
在eclipse中使用junit -
帅先勃:
...
Java设计模式之生产者消费者模式 -
liberD:
我昨天试了,报了很多的错误。请问,您遇到这种情况了吗?
git安装
At this point, the client code should start to compile but there is still more to do before we can run it. We need some utility classes for the dispatcher and Gin:
CachingDispatchAsync.java
view source
<object id="highlighter_932213_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.client;
02.
import
java.util.HashMap;
03.
import
java.util.Map;
04.
import
com.google.gwt.user.client.rpc.AsyncCallback;
05.
import
com.google.inject.Inject;
06.
import
net.customware.gwt.dispatch.client.DispatchAsync;
07.
import
net.customware.gwt.dispatch.shared.Action;
08.
import
net.customware.gwt.dispatch.shared.Result;
09.
/**
10.
* Dispatcher which support caching of data in memory
11.
*
12.
*/
13.
public
class
CachingDispatchAsync
implements
DispatchAsync {
14.
private
DispatchAsync dispatcher;
15.
private
Map, Result> cache =
new
HashMap, Result>();
16.
@Inject
17.
public
CachingDispatchAsync(
final
DispatchAsync dispatcher) {
18.
this
.dispatcher = dispatcher;
19.
}
20.
/*
21.
* (non-Javadoc)
22.
* @see net.customware.gwt.dispatch.client.DispatchAsync#execute(A, com.google.gwt.user.client.rpc.AsyncCallback)
23.
*/
24.
public
, R
extends
Result>
void
execute(
final
A action,
final
AsyncCallback callback) {
25.
dispatcher.execute(action, callback);
26.
}
27.
/**
28.
* Execute the give Action. If the Action was executed before it will get fetched from the cache
29.
*
30.
* @param Action implementation
31.
* @param Result implementation
32.
* @param action the action
33.
* @param callback the callback
34.
*/
35.
@SuppressWarnings
(
"unchecked"
)
36.
public
, R
extends
Result>
void
executeWithCache(
final
A action,
final
AsyncCallback callback) {
37.
final
Result r = cache.get(action);
38.
39.
if
(r !=
null
) {
40.
callback.onSuccess((R) r);
41.
}
42.
else
{
43.
dispatcher.execute(action,
new
AsyncCallback() {
44.
public
void
onFailure(Throwable caught) {
45.
callback.onFailure(caught);
46.
}
47.
public
void
onSuccess(R result) {
48.
cache.put((Action) action, (Result) result);
49.
callback.onSuccess(result);
50.
}
51.
});
52.
}
53.
}
54.
/**
55.
* Clear the cache
56.
*/
57.
public
void
clear() {
58.
cache.clear();
59.
}
60.
}
GreetingClientModule.java
view source
<object id="highlighter_727479_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.client.gin;
02.
import
net.customware.gwt.presenter.client.DefaultEventBus;
03.
import
net.customware.gwt.presenter.client.EventBus;
04.
import
net.customware.gwt.presenter.client.gin.AbstractPresenterModule;
05.
import
net.customware.gwt.presenter.client.place.PlaceManager;
06.
import
co.uk.hivedevelopment.greet.client.CachingDispatchAsync;
07.
import
co.uk.hivedevelopment.greet.client.mvp.AppPresenter;
08.
import
co.uk.hivedevelopment.greet.client.mvp.GreetingPresenter;
09.
import
co.uk.hivedevelopment.greet.client.mvp.GreetingResponsePresenter;
10.
import
co.uk.hivedevelopment.greet.client.mvp.GreetingResponseView;
11.
import
co.uk.hivedevelopment.greet.client.mvp.GreetingView;
12.
import
com.google.inject.Singleton;
13.
public
class
GreetingClientModule
extends
AbstractPresenterModule {
14.
@Override
15.
protected
void
configure() {
16.
bind(EventBus.
class
).to(DefaultEventBus.
class
).in(Singleton.
class
);
17.
bind(PlaceManager.
class
).in(Singleton.
class
);
18.
19.
bindPresenter(GreetingPresenter.
class
, GreetingPresenter.Display.
class
, GreetingView.
class
);
20.
bindPresenter(GreetingResponsePresenter.
class
, GreetingResponsePresenter.Display.
class
, GreetingResponseView.
class
);
21.
22.
bind(AppPresenter.
class
).in(Singleton.
class
);
23.
bind(CachingDispatchAsync.
class
);
24.
}
25.
}
GreetingGinjector.java
view source
<object id="highlighter_347758_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.client.gin;
02.
import
net.customware.gwt.dispatch.client.gin.ClientDispatchModule;
03.
import
net.customware.gwt.presenter.client.place.PlaceManager;
04.
import
co.uk.hivedevelopment.greet.client.mvp.AppPresenter;
05.
import
com.google.gwt.inject.client.GinModules;
06.
import
com.google.gwt.inject.client.Ginjector;
07.
@GinModules
({ ClientDispatchModule.
class
, GreetingClientModule.
class
})
08.
public
interface
GreetingGinjector
extends
Ginjector {
09.
AppPresenter getAppPresenter();
10.
PlaceManager getPlaceManager();
11.
}
Now we tie all this together by replacing the existing module entry class with the following:
GreetMvp.java
view source
<object id="highlighter_318282_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.client;
02.
import
co.uk.hivedevelopment.greet.client.gin.GreetingGinjector;
03.
import
co.uk.hivedevelopment.greet.client.mvp.AppPresenter;
04.
import
com.google.gwt.core.client.EntryPoint;
05.
import
com.google.gwt.core.client.GWT;
06.
import
com.google.gwt.user.client.ui.RootPanel;
07.
public
class
GreetMvp
implements
EntryPoint {
08.
private
final
GreetingGinjector injector = GWT.create(GreetingGinjector.
class
);
09.
public
void
onModuleLoad() {
10.
final
AppPresenter appPresenter = injector.getAppPresenter();
11.
appPresenter.go(RootPanel.get());
12.
injector.getPlaceManager().fireCurrentPlace();
13.
}
14.
}
Server Components
Okay, now let's define the server side. We need to configure Guice and the dispatch handler plus we need to provide an implementation for the SendGreeting action.
SendGreetingHandler.java
view source
<object id="highlighter_877314_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.server.handler;
02.
import
javax.servlet.ServletContext;
03.
import
javax.servlet.http.HttpServletRequest;
04.
import
net.customware.gwt.dispatch.server.ActionHandler;
05.
import
net.customware.gwt.dispatch.server.ExecutionContext;
06.
import
net.customware.gwt.dispatch.shared.ActionException;
07.
import
org.apache.commons.logging.Log;
08.
import
co.uk.hivedevelopment.greet.shared.rpc.SendGreeting;
09.
import
co.uk.hivedevelopment.greet.shared.rpc.SendGreetingResult;
10.
import
com.google.inject.Inject;
11.
import
com.google.inject.Provider;
12.
public
class
SendGreetingHandler
implements
ActionHandler<SendGreeting, SendGreetingResult> {
13.
private
final
Log logger;
14.
private
final
Provider<ServletContext> servletContext;
15.
private
final
Provider<HttpServletRequest> servletRequest;
16.
@Inject
17.
public
SendGreetingHandler(
final
Log logger,
18.
final
Provider<ServletContext> servletContext,
19.
final
Provider<HttpServletRequest> servletRequest) {
20.
this
.logger = logger;
21.
this
.servletContext = servletContext;
22.
this
.servletRequest = servletRequest;
23.
}
24.
@Override
25.
public
SendGreetingResult execute(
final
SendGreeting action,
26.
final
ExecutionContext context)
throws
ActionException {
27.
final
String name = action.getName();
28.
29.
try
{
30.
String serverInfo = servletContext.get().getServerInfo();
31.
32.
String userAgent = servletRequest.get().getHeader(
"User-Agent"
);
33.
34.
final
String message =
"Hello, "
+ name + "!
35.
I am running " + serverInfo
36.
+ ".
37.
It looks like you are using:
38.
" + userAgent;
39.
40.
//final String message = "Hello " + action.getName();
41.
42.
return
new
SendGreetingResult(name, message);
43.
}
44.
catch
(Exception cause) {
45.
logger.error(
"Unable to send message"
, cause);
46.
47.
throw
new
ActionException(cause);
48.
}
49.
}
50.
@Override
51.
public
void
rollback(
final
SendGreeting action,
52.
final
SendGreetingResult result,
53.
final
ExecutionContext context)
throws
ActionException {
54.
// Nothing to do here
55.
}
56.
57.
@Override
58.
public
Class<SendGreeting> getActionType() {
59.
return
SendGreeting.
class
;
60.
}
61.
}
DispatchServletModule.java
view source
<object id="highlighter_506662_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash"> </object>
print? 01.
package
co.uk.hivedevelopment.greet.server.guice;
02.
import
net.customware.gwt.dispatch.server.service.DispatchServiceServlet;
03.
import
com.google.inject.servlet.ServletModule;
04.
public
class
DispatchServletModule
extends
ServletModule {
05.
@Override
06.
public
void
configureServlets() {
07.
// NOTE: the servlet context will probably need changing
08.
serve(
"/greetmvp/dispatch"
).with(DispatchServiceServlet.
class
);
09.
}
10.
}
发表评论
-
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 1621LogProvider.java view sou ... -
Google Web Toolkit (GWT) MVP Example (3)
2009-11-24 18:07 1416GreetingResponsePresenter.java ... -
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 3832本文转自: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的一个重要里程碑,带来了许多改进和新特性,使得...
Google Web Toolkit(GWT)是一款由Google推出的开源框架,专为Java开发者设计,旨在简化和加速Web应用程序的开发过程。它允许开发者使用Java语言编写前端代码,并将其编译成高性能的JavaScript,从而在浏览器上运行...
《加速GWT:构建企业级Google Web Toolkit应用》是一本深度探讨如何利用Google Web Toolkit(GWT)构建高性能Ajax应用程序的专业书籍。本书作者Vipul Gupta深入解析了GWT的核心功能,以及如何通过GWT生成优化的...
**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)