2010年7月28日_周三_Working with AJAX capabilities of the Web ADF_overview
Posted on 2010-07-29 07:04 星尘的天空 阅读(185) 评论(0) 编辑 收藏 举报/****************************************************/
// Working with AJAX capabilities of the Web ADF
//arcgisserverHelp_creating ArcGIS Server solution
//_developting application
//_webControls
//_ajax capabilities of web adf controls
//_overview
//
/***************************************************/
Developing applications using the Web ADF - Web controls |
|
Working with AJAX capabilities of the Web ADF
使用Web ADF架构的AJAX功能工作
ASP.NET supports both synchronous and asynchronous communication with Web applications. The Web ADF controls are designed leverage(力量,影响) two AJAX patterns packaged for use with ASP.NET: ASP.NET script callbacks and ASP.NET AJAX. Both are provided by Microsoft to enhance the Web application developer and user experience. It is recommended that(建议) you are familiar with AJAX and ASP.NET technologies and concepts before proceeding(进行).
ASP.NET 支持和web应用程序进行即时或者异步的交流。Web ADF控件被设计为两种AJAX类型的包裹在ASP.NET中使用:ASP.NET脚本回调和ASP.NET AJAX。上面的两种都是有微软提供用来增强web应用个程序开发者和用户的体验。
建议你应该熟悉AJAX和ASP.NET技术和概念在进行开发前。
As a Web ADF developer, you have the option to select which AJAX pattern you will utilize in your Web application. In version 9.2, the Web ADF only supported the ASP.NET script callback framework. As a result, many existing applications have been built on the callback model for asynchronous communication. This model remains valid(有根据,有效地) and supported in 9.3. However, the 9.3 Web ADF also supports the latest Microsoft AJAX solution, ASP.NET AJAX. The Web ADF controls are only designed to use one model for asynchronous communication per page. The presence of an ASP.NET AJAX ScriptManager control in a page dictates which model will be used. If a ScriptManager is present, Web ADF controls will use the ASP.NET AJAX partial postback model. If a ScriptManager is not present in the page, the Web ADF controls will use the ASP.NET script callback model. Note, the ScriptManager must be the first control in the page.
作为一个web ADF 开发者,你有权利选择在你的web 应用程序中使用哪种类型的AJAX。
在9.2版本,web adf 仅仅支持asp.net 脚本回调框架。 结果,很多已经存在的应用程序都是建立在基于回调模型实现异步的交流。这个模型在9.3里面仍然有效并被支持。尽管如此,9.3版本的web adf还支持最新版本的微软AJAX解决方案:ASP.NET AJAX。 Web adf 被设计为在每一个页面都仅仅支持一种模式的异步交流。页面中的ScriptManager控件控制着哪种模型被被使用。如果在页面中出现一个ScriptManagerweb adf控件,那么WEB ADF控件就会使用asp.net 脚本回调模型。 需要注意的是,ScriptManager必须是页面中的第一个控件。
ASP.NET AJAX provides both a client and server side solution. In all cases, Web ADF client-side JavaScript libraries use ASP.NET AJAX client-side JavaScript libraries to provide a foundation for a comprehensive scriptable environment for AJAX solutions within a browser. On the server, Web ADF components have the option of utilizing ASP.NET AJAX components and their framework to work with the partial postback pattern.
ASP.NET AJAX提供来客户端和服务器端的解决方案。 在所有的情况下,web adf客户端脚本类库使用asp.ent ajax客户端类库在浏览器里面提供一个综合的,脚本可编辑的环境。 在服务器端,web adf租金按有选择使用asp.net ajax组件以及他们的框架来同回调类型一起工作的权利。
In many cases, working with AJAX capabilities in the Web ADF will differ depending on which AJAX solution you choose. However, there are some common components and concepts shared by both. In general, any client-server interaction in the Web ADF will involve an action request and response, followed by subsequent(随后的) asynchronous(异步的) requests to handle changes made during the initial postback. In most cases, an action request is initiated by a user action in the browser (e.g. zooming in on a map). If the action request is sent to the current page, it may be a synchronous full postback, an asynchronous partial postback, or a callback (also a type of postback). 在大多数情况下,发起行动的要求是在浏览器的用户操作
在很多的情况下,根据你选择的AJAX解决方案,在web adf 中使用的ajax技术也是不尽相同的。 尽管如此,这两者还是有很多通用的组件以及相同的概念的。一般来说,任何web adf 下的客户端—服务器端的交互都是通过请求,回复(回答),然后伴随着异步请求来处理在初始化回发时发生的变化。在多数情况下,发起动作请求,都是由浏览器里面的客户动作发起的。如果那个动作请求被发送到当前的页面,他有可能是同步的全部回发,一个异步的部分回发,或者一个回调(也是一种类型的回发)
Each postback to a page in a Web application will iterate(重做) through the page lifecycle. The type of postback will dictate the which lifecycle events are triggered(触发,引起) and the response(回应) content. Subsequent requests can be asynchronous and may iterate through the page lifecycle or just request a remote resource, like an image. As a result, a single user action in the browser may generate multiple requests, some of which iterate through the page lifecycle. For a postback to a page, iterating through the page lifecycle is required because the page and its contents must be reconstructed to process a request.
每一web 应用程序页面的回发都会页面的生命周期中重做。回发的类型将会控制哪种生命周期事件被触发并且回应。随后的请求将会被异步并且在页面的生命周期里面重发或者仅仅一个远程资源的请求,比如一个图像。 结果,浏览器里面用户的一个单独的工作可能会产生多个请求,其中的一些会在页面的整个寿命周期里面重发发送。对于返回页面的一个回发,在页面的生命周期内重发发送是要求的,这是因为页面和她里面的内容必须被从新创建来处理一个请求。
Regardless of which Microsoft AJAX pattern is used, the Web ADF includes an internal framework to synchronize changes to the state of client and server content in an asynchronous environment. This framework, termed(把**成为) the "callback result framework", is founded on Web ADF "callback results" which are messages generated on the server to communicate changes with the client. The following logical areas in the Web ADF are integral to leveraging the callback result framework and Microsoft AJAX solutions. As a developer, you can utilize one or more of these component areas to create and manage custom Web ADF AJAX solutions.
JavaScript libraries to manage postbacks on the client
不管微软的那种ajax类型被使用,包括了内部框架的web adf 来同步改变客户端的状态并在异步环境下改变服务器端内容。整个框架,被成为“回发结果框架”
,是建立在web adf 回发结果。这些结果是在服务器端产生的,用来和客户端尽交流改变。后面的在web adf中的逻辑区域,影响着回发结果框架和微软的ajax 解决方案。作为一个开发者,你可以利用一个或者多个这样类型的组件区域创建和管理web adf ajax 解决方案。JavaScript 类库来管理客户端的回发。
In version 9.2, the Web ADF included a set of JavaScript libraries built on(基于) the ASP.NET callback framework JavaScript. In addition, the Web ADF JavaScript was not designed to be utilized publicly or customized. In 9.3 this has changed. The ASP.NET AJAX JavaScript libraries have been leveraged to enhance Web ADF capabilities with a public Web ADF JavaScript Library . As a result, Web ADF applications can take advantage of pure client scripting solutions to enhance the usability(可用性) and performance of the application. The ASP.NET AJAX JavaScript libraries are utilized regardless of the AJAX solution used on the server (for example, even when using the callback model). This is possible because the AJAX Control Toolkit is included with the Web ADF. The AJAX Control Toolkit, packaged as a single assembly, provides a consistent, Microsoft supported, public platform on which to deploy ASP.NET AJAX solutions. It includes the core client and server components included with ASP.NET AJAX (Extensions) as well as other components to support the usability and distribution of Web solutions built on ASP.NET AJAX.
9.2版本,web adf 包含一系列的基于asp.net回发框架脚本的JavaScript类库。
另外,Web ADF JavaScript并不是设计为公共利用或者定制。9.3版本这个已经改变了。ASP.NET AJAX JavaScript类库已经通过一个公共的Web ADF JavaScript Library 来增强来web adf 的能力。 结果,
By default, the Web ADF JavaScript Library consists of a set of JavaScript files, embedded(把**嵌入) as resources with the Web ADF controls. Only those JavaScript files required to support the Web ADF controls in the application are streamed to the browser client.
默认情况下,web adf javascript 类库包含一系列的javascript文件,这些文件被当做资源嵌入到web adf 控件里面。 只有这些在应用程序中支持web adf控件的JavaScript脚本文件被当做数据流进入客户端的浏览器里面。
From response perspective(观点,视角 )the ESRI.ADF.System.processCallbackResult function is most important. Most Web ADF controls generate callback results when their state changes on the server. The ESRI.ADF.System.processCallbackResult function is designed to parse and process callback results from Web ADF controls and update their content, at runtime, on the client.
站在反应的角度来说, ESRI.ADF.System.processCallbackResult的功能就更加重要了。大多数的web adf 控件当他们在服务器端的状态发生改变后就就会产生一个回调结果。ESRI.ADF.System.processCallbackResult 的功能就是用来在客户端运行的时候分析和处理来自于web adf 的回调结果,并更新他们的内容,
The Toolbar control provides a prepackaged(预先包装好的商品) framework for adding client-side tools to interact with Web ADF controls. You only need to create a class on the server that implements the appropriate interface (depending on the type of toolbar item) and add that class to the Toolbar. Implementation code in the toolbar item class can interact(相互作用) and change any server-side resource and the postback is managed for you. This is the easiest way to tap(开发) into the AJAX capabilities of the Web ADF, but requires you to work within the context of a Toolbar control.
工具条控件提供一个预先包装好的框架添加客户端工具来和web adf控件进行交互。你只需在服务器端添加一个类来实现属性接口并将这个类添加到工具条。
工具条中工具的类的实施代码会相互影响,并且改变任何一个服务器端的资源,并且 回调也为你设置好来。这是开发web adf 的ajax 功能最简单的方式,但是这个要求你在工具条的环境下工作。
Public callback properties on each Web ADF control
Web adf 控件中的公共对调属性
All Web ADF controls implement the System.Web.UI.ICallbackEventHandler and System.Web.UI.IPostBackEventHandler interfaces handle asynchronous requests and generate responses. When a Web ADF control is modified(修改) on the server, it generates a response to tell the client how to update the control. To do this, each Web ADF control maintains a CallbackResults property. The CallbackResults property stores a collection of callback results the control will send to the client browser to be processed by the processCallbackResult() function. Callback results are messages serialized(连续,连载) using JSON , JavaScript Object Notation, an efficient, human-readable, data exchange format. If you want to interact with a Web ADF control apart from the Toolbar control and toolbar items, you often will need to retrieve(检索) messages from the CallbackResults property and return them to the client. When implementing ICallbackEventHandler to support the callback model, messages are returned from the GetCallbackResult() method. When implementing IPostBackEventHandler to support the partial postback model, messages are added as data items to a ScriptManager in the RaisePostBackEvent() method.
所有的web adf 控件都实现来System.Web.UI.ICallbackEventHandler and System.Web.UI.IpostBackEventHandler 接口处理异步的请求并且产生结果, 当一个web adf 控件在无武器端被修改后,他产生了一个请求来告诉客户端如何去更新这个控件。为来完成这个动作,每一个web adf 组件都保持这个一个回调结果的属性。CallbackResults 属性存储在一个回调结果集合里面,这个集合将会被发送到客户端的浏览器里面被processCallbackResult函数来处理。使用json使得回调的结果成为一些连续的消息。 除了工具条控件和工具项意味如果你想和一个web adf 控件进行交互,你就需要从回调结果属性里面检索消息并将他们发送到客户端。 当通过实现IcallbackEventHandler来支持回调模型,就从GetCallbackResult()返回信息。当实现IpostBackEventHandler 来支持 部分回调模型,信息在RaisePostBackEvent()函数里面就像数据项一样被添加到脚本管理器中
Custom classes to create and manage callback messages
//自定义类用来创建和管理回调信息
The CallbackResults property on a Web ADF control returns a CallbackResultCollection. This collection can be modified(修改,更改) to include custom CallbackResult objects. Custom CallbackResult objects can be used to interact with non-Web ADF content in the Web page (e.g. HTML table, GridView, images, text). The main benefit being that you can use the existing Web ADF JavaScript libraries to change non-Web ADF content on the client instead of writing your own JavaScript.
一个web adf 控件的CallbackResults 属性返回一个CallbackResultCollection。这个集合可以被修改来包含自定义CallbackResult对象。 自定义CallbackResult对象可以在web页面被用来和非web adf 控件进行交互。最大的好处就是你可以在客户端使用一个已经存在的web adf JavaScript类库来改变非web adf 的内容而不用写你自己的类库。
Choosing which AJAX solution works for you depends on business rules, application requirements, and technical expertise(专门支持,专长). Both ASP.NET script callbacks and ASP.NET AJAX are supported equally. In either case, is important to understand the content and capabilities of the Web ADF callback results framework. It is discussed in detail in the topic Working with CallbackResults . Once you decide which AJAX solution you will use with Web ADF controls in a Web page, underlying techniques for working the AJAX capabilities of the Web ADF will differ. This includes the techniques for packaging callback results in an asynchronous Web response. Each AJAX pattern is presented in a separate topic: ASP.NET callback solutions and ASP.NET AJAX partial postback solutions
选择哪个ajax 解决方案为你工作依赖于事情的规矩,应用程序的要求和技术专长。 ASP.NET 脚本回调和ASP.NET AJAX 都被同等的支持。在任何一中情况下理解web adf 回调结果框架都是很重要的。 更详细的消息请查看Working with CallbackResults。 一旦确定在一个web 页面你将哪种ajax解决方案和web adf 控件一起使用,应该理解web adf 控件的ajax 功能是不同的。 这个就包括在一个异步web 响应包装回调结果的技术。 每一个AJAX 类型出现在一个独立的话题里面:ASP.NET callback solutions 和ASP.NET AJAX partial postback solutions