- 浏览: 115350 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (135)
- java (135)
- [转]c# 画圆角矩形 (1)
- 设计模式生活实例 (1)
- .nET2.0小技巧 (1)
- 从另一个角度看敏捷实践(一)--IPM:承诺的仪式 (1)
- javascript字符串转json对象 (1)
- 使用BeanUtils时,Date类型值为空的解决方法 (1)
- Lenovo V460+Ubuntu 11.10 无线网问题 (1)
- Lucene 索引和搜索过程核心类详解 (1)
- Android短信编解码方式 (1)
- 股神巴菲特十大致富秘籍 (1)
- Map遍历的三种方法 (1)
- Android中用Toast.cancel()方法优化toast内容的显示 (1)
- ViewFlipper “Receiver not registered” Error (1)
- javax.xml.transform.TransformerFactoryConfigurationError (1)
- JNI调用的注意事项 (1)
- JUnit单元测试感悟 (1)
- 用C#写定时关机的程序 (1)
- ASP.NET开发工具Web Matrix介绍 (1)
- MapXtreme2004代码 MapControl控件中显示地图文件 (1)
- 《使用 Microsoft .NET 的企业解决方案模式》读书笔记3 (1)
- 微创短信开发平台 (1)
- 谈谈Q+平台的技术实现 (1)
- 手机防盗软件实现(源码) (1)
- 虚析构函数(总结 帖子) (1)
- c语言中去除const修饰 (1)
- ORA-01012: not logged on 解决办法 (1)
- paypal提现如何省钱 (1)
- 数独suduku (1)
- MyISAM InnoDB 区别 (1)
- 随 笔 (1)
- Android上的log,日志相关 (1)
- 百度质量部实习居然通过了~ (1)
最新评论
-
野狐禅:
ext.get('imagebrowse') is null
ExtJs上传图片预览功能 -
zhuyl_wind:
不切实际,呵呵
[]5年内买车买房-理财篇 -
in南京:
关键你那两千块钱就够交一个多月的房租!换个城市你那六百也远远不 ...
[]5年内买车买房-理财篇 -
javac_xinyun:
呵呵,看完了,确实不错,貌似第一年的房租每月算进去 ,人际关系 ...
[]5年内买车买房-理财篇 -
dishikun:
貌似很不错,就是没把房租算进去!
[]5年内买车买房-理财篇
//官网参考地址:http://directwebremoting.org/dwr/index.html
<h1 style="font-size: 150%;">direct web remoting</h1>dwr is a java library that enables java on the server and javascript in a browser to interact and call each other as simply as possible.
dwr is easy ajax for java
dwr will generate the javascript to allow web browsers to securely call into java code almost as if it was running locally. it can marshal virtually any data including collections, pojos, xml and binary data like images and pdf files. all that is required is a security policy that defines what is allowed.
with reverse ajax, dwr allows java code running on a server to use client side apis to publish updates to arbitrary groups of browsers. this allows interaction 2 ways - browser calling server and server calling browser. dwr supports comet, polling and piggyback (sending data in with normal requests) as ways to publish to browsers.
dwr provides integration with spring, struts, guice, hibernate and others.
dwr is a rpc library which makes it easy to call java functions fromjavascript and to call javascript functions from java (a.k.a reverseajax).
dwr consists of two main parts:
- a java servlet running on the server that processes requests andsends responses back to the browser.
- javascript running in the browser that sends requests and candynamically update the webpage.
this method of remoting functions from java to javascript gives dwrusers a feel much like conventional rpc mechanisms like rmi or soap,with the benefit that it runs over the web without requiringweb-browser plug-ins.
<pre><create creator="new" javascript="jdate"> <param name="class" value="java.util.date"/> </create></pre>
the new creator that we used above uses the public no-args constructor that all javabeans must have. it is also worth remembering that dwr has one restriction:
- avoid reserved javascript words; methods named after reserved words are automatically excluded. most javascript reserved words are also java reserved words, so you won't be having a method called "try()" anyway. however the most common gotcha is "delete()", which has special meaning in javascript but not java.
the javascript attribute is required - it gives your newly created object a name in the browser. you should avoid using javascript reserved words.
the scope attribute is largely the same as the scope attribute as defined by the servlet spec. it allows you to specify what a bean is available to. the options are "application", "session", "request", "page" and an additional scope "script". the first 4 of these values should be familiar to servlet and jsp developers. "script" scope allows you to have something similar to an http session that is tied to an id in a page rather than in a cookie.
the scope attribute is optional. it defaults to "page".
dwr comes with some small javascript libraries to help you:
- engine.js: handles allserver communication
- util.js: helps you alterweb pages with the data you got from the server (and a few neat extrastoo)
http://directwebremoting.org/dwr/introduction/getting-started.html
//http://directwebremoting.org/dwr/documentation/browser/util/addoptions.html
//http://directwebremoting.org/dwr/documentation/browser/util/lists.html
//例子
下载2.0版本
根据下载的版本配置,也可根据上面来配置,但官网上配置的版本是3.0的,所以dwr.xml需从2.0中得到dtd。
重点是下载中的例子
在eclipse中运行项目,找出下面的内容(其中1、3是要掌握的,2一般少用):
tutorial style examples in this war file:
- dynamic text: a very simple documented example that updates a page with some text.
- resource forwarding: how to dynamically include the contents of one page in another.
- editable table: another simple documented example that allows the user to edit a table of data.
<script id="gtbtranslateelementcode">var gtbtranslateonelementloaded;(function(){var lib = null;var checkreadycount = 0;function sendmessage(message, attrs) { var data = document.getelementbyid(&quot;gtbtranslateelementcode&quot;); for (var p in attrs) { data.removeattribute(p); } for (var p in attrs) { if (&quot;undefined&quot; != typeof attrs[p]) { data.setattribute(p, attrs[p]); } } var evt = document.createevent(&quot;events&quot;); evt.initevent(message, true, false); document.dispatchevent(evt);}function checklibready (){ var ready = lib.isavailable(); if (ready) { sendmessage(&quot;gtbtranslatelibready&quot;, {&quot;gtbtranslateerror&quot; : false}); return; } if (checkreadycount++ &gt; 5) { sendmessage(&quot;gtbtranslatelibready&quot;, {&quot;gtbtranslateerror&quot; : true}); return; } settimeout(checklibready, 100);}gtbtranslateonelementloaded = function () { lib = google.translate.translateservice({}); sendmessage(&quot;{evt_loaded}&quot;, {}, []); var data = document.getelementbyid(&quot;gtbtranslateelementcode&quot;); data.addeventlistener(&quot;gtbtranslate&quot;, ontranslaterequest, true); data.addeventlistener(&quot;gtbtranslatecheckready&quot;, oncheckready, true); data.addeventlistener(&quot;gtbtranslaterevert&quot;, onrevert, true); checklibready();};function oncheckready() { var ready = lib.isavailable(); sendmessage(&quot;gtbtranslatelibready&quot;, {&quot;gtbtranslateerror&quot; : !ready});}function ontranslaterequest() { var data = document.getelementbyid(&quot;gtbtranslateelementcode&quot;); var orig = data.getattribute(&quot;gtboriginallang&quot;); var target = data.getattribute(&quot;gtbtargetlang&quot;); lib.translatepage(orig, target, onprogress);}function onprogress(progress, opt_finished, opt_error) { sendmessage(&quot;gtbtranslateonprogress&quot;, {&quot;gtbtranslateprogress&quot; : progress, &quot;gtbtranslatefinished&quot; : opt_finished, &quot;gtbtranslateerror&quot; : opt_error});}function onrevert() { lib.restore();}})(); (function(){var d=window,e=document;function f(b){var a=e.getelementsbytagname(&quot;head&quot;)[0];a||(a=e.body.parentnode.appendchild(e.createelement(&quot;head&quot;)));a.appendchild(b)}function _loadjs(b){var a=e.createelement(&quot;script&quot;);a.type=&quot;text/javascript&quot;;a.charset=&quot;utf-8&quot;;a.src=b;f(a)}function _loadcss(b){var a=e.createelement(&quot;link&quot;);a.type=&quot;text/css&quot;;a.rel=&quot;stylesheet&quot;;a.charset=&quot;utf-8&quot;;a.href=b;f(a)}function _isns(b){for(var b=b.split(&quot;.&quot;),a=d,c=0;c&lt;b.length;++c)if(!(a=a[b[c]]))return!1;return!0}function _setupns(b){for(var b=b.split(&quot;.&quot;),a=d,c=0;c&lt;b.length;++c)a=a[b[c]]||(a[b[c]]={});return a}d.addeventlistener&amp;&amp;typeof e.readystate==&quot;undefined&quot;&amp;&amp;d.addeventlistener(&quot;domcontentloaded&quot;,function(){e.readystate=&quot;complete&quot;},!1);if (_isns('google.translate.element')){return}var c=_setupns('google.translate._const');c._cl='zh-cn';c._cuc='gtbtranslateonelementloaded';c._cac='';c._cam='lib';var h='translate.googleapis.com';var b=(window.location.protocol=='https:'?'https://':'http://')+h;c._pah=h;c._pbi=b+'/translate_static/img/te_bk.gif';c._pci=b+'/translate_static/img/te_ctrl3.gif';c._phf=h+'/translate_static/js/element/hrs.swf';c._pli=b+'/translate_static/img/loading.gif';c._plla=h+'/translate_a/l';c._pmi=b+'/translate_static/img/mini_google.png';c._ps=b+'/translate_static/css/translateelement.css';c._puh='translate.google.com';_loadcss(c._ps);_loadjs(b+'/translate_static/js/element/main_zh-cn.js');})();</script>
发表评论
-
百度质量部实习居然通过了~
2012-02-08 12:23 958[size=small;]? ? ?本来打算在软工所苦 ... -
Android上的log,日志相关
2012-02-07 14:18 1491摘自:http://blog.csdn.net/met ... -
随 笔
2012-02-04 13:39 568金风玉露一相逢,便胜却人间无数。英文版: chemis ... -
MyISAM InnoDB 区别
2012-02-02 16:59 702<h1 id="artibody ... -
数独suduku
2012-01-31 14:38 887sudu sudu sudu sudu sudu su ... -
paypal提现如何省钱
2011-12-28 16:58 1182据PayPal中文注册得知,如今很多收样品费的外贸商户 ... -
ORA-01012: not logged on 解决办法
2011-12-28 13:08 3432<span style="font-f ... -
c语言中去除const修饰
2011-12-21 10:54 1386[size=16px;]<span style= ... -
虚析构函数(总结 帖子)
2011-12-21 09:54 673<span style="" ... -
手机防盗软件实现(源码)
2011-12-20 12:54 916<a href="http://blo ... -
谈谈Q+平台的技术实现
2011-12-20 09:49 935这篇文章是我个人 ... -
微创短信开发平台
2011-12-19 11:39 737在网上闲逛,发现了一个站点,微创短信开发平台(http ... -
《使用 Microsoft .NET 的企业解决方案模式》读书笔记3
2011-12-19 10:24 724第3章 Web表示模式 没有一个设计策略能够适合所有情 ... -
MapXtreme2004代码 MapControl控件中显示地图文件
2011-12-15 14:29 859::<?xml:namespace prefix ... -
ASP.NET开发工具Web Matrix介绍
2011-12-15 13:39 937<p class="MsoPlain ... -
用C#写定时关机的程序
2011-12-15 11:14 676</span></font>& ... -
JUnit单元测试感悟
2011-12-14 11:29 836<p class="MsoNorma ... -
JNI调用的注意事项
2011-12-14 09:34 720JNI的简单教程网上很多,看看就能够明白,照着操作也基 ... -
javax.xml.transform.TransformerFactoryConfigurationError
2011-12-13 13:34 815<span style="" ... -
ViewFlipper “Receiver not registered” Error
2011-12-12 10:59 1098偶尔出现这个错误: <span> < ...
相关推荐
DWR 入门DWR 入门DWR 入门DWR 入门DWR 入门欢迎使用 STRUT2 DWR 入门STRUT2 DWR 入门STRUT2 DWR 入门STRUT2 DWR 入门
Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr...
DWR入门操作手册DWR入门操作手册DWR入门操作手册DWR入门操作手册
实例+说明 学完就会DWR dwr入门资料
DWR中文文档 dwr.jar dwr入门教程 很好的入门资料!!
dwr入门必看的资源,本人通过这个就很好的学习dwr
【软件工程】DWR入门教程
SSH CRM项目DWR入门源码(4)通过DWR实现动态树源码(5) var sjzdflArr; DWREngine.setAsync(false); SjzdflDAO.findAll(load); DWREngine.setAsync(true); function load...
dwr入门中web.xml配置 dwr.xml的位置和配置路径 ,附带测试小案例
最完整的DWR入门文档及DWR使用案例,让你轻松使用了解AJAX技术
dwr入门资料,简单入门,让你轻松掌握dwr
一个DWR入门教程,压缩包下有一个工程,直接在MYECLIPSE中导入工程,运行就可以,一个WORD文档介绍DWR的步骤
DWR入门教程及实例(含源代码),DWR的入门教程,jar文件夹中提供DWR所用jar包,运行源代码时需导入此文件夹中所有jar包
DWR入门教程.pdf
DWR入门程序---计算输入的两个数之和.rar DWR入门程序---计算输入的两个数之和.rar DWR入门程序---计算输入的两个数之和.rar
dwr实例 - 这是本人,开发的:小游戏 [大家一起来赚钱] 本例子可做为dwr入门级应用; 有什么问题请和我沟通;
DWR入门操作手册, 适用于DWR的初学者,很基础的,推荐新手下载
dwr入门例子 包含类型转换 dwr实战.doc
(网络整理资料)DWR入门与应用,手把手教你从配置到实例的应用