[Ajax系列翻译文章]-ZK架构一览

ZK Architecture Overview/ZK架构一览from 每天挖一点 by Minor - 矿工
ZK Architecture Overview Chinese Edition
Architecture OverviewZK架构一览
Prefix前言
Overa decade of evolution, Web applications evolved from static HTML pages,to Dynamic HTML pages, to applets and Flash, and, finally, to Ajaxtechnologies.
经过这十几年的发展演变,Web应用从静态的HTML页面演化成动态HTML页面,然后是Applet和Flash,最终到了Ajax技术。
Challenges in AjaxAjax面临的挑战
When providing the interactivity to fulfill user’s demand, Ajaxincreases the complexities of applications and skill prerequisites tothe already costly development of Web applications.
在满足用户需求而提供的交互性活动时,Ajax增加了应用的复杂度和本就费用高昂的web应用开发所必需的技能。
Incompatible and buggy JavaScript API among different browsers
在不同浏览器间不可共存且容易产生bug的Javascript API
Maintenance overhead to replicate business logic at the client, particular in a different programming language.对于用户来说重复业务逻辑产生的维护开销,尤其是在不同的编程语言情况下
Danger of exposition of application data model and business logic to the client经应用数据模型和业务逻辑暴露给用户的危险
Communication headache to maintain data consistency between the client and the server asynchronously令人头疼的使客户端和服务器端保持一致的异步通信。
Current Solutions当前解决方案
Inorder to deliver a manageable Ajax solution, many frameworks orlibraries have been developed. The most straight forward way is toprovide ready-to-use JavaScript components. However, applicationdevelopers have to manipulate these components, glue them with businesslogic at the client, and develop an application-specific way toexchange data with the server dynamically.
为了提供一个可管理的Ajax解决方案,目前已经有许多的框架或者类库。最直接的方式是提供立即可用的Javascript控件。然而,应用程序开发人员必须生成这些控件,在客户端中加入业务逻辑,并且开发一个应用特定的方式来与服务器端交互数据。
Inshort, only the first one of above challenges was addressed. The restof challenges, more or less, remain the hassles of applicationdevelopers. Is it intrinsic to the development of Web applications? Orthe traditional Web application programming model is simply inadequate?
简而言之,这里只解决了前面提到过的Ajax面临的挑战中的第一个。其他的挑战,或多或少还是会继续不断地骚扰我们的应用开发人员。难道这就是Web应用程序开发的本质么?或者只是传统的Web应用编程模型已经不适用了呢?
ZK ArchitectureZK架构
Inresponse to these challenges, ZK delivers the intuitive desktopprogramming model to Web applications with event-driven,component-based, and server-centric architecture. In addition, ZKprovides the modern development of UI technologies, such markuplanguages to design UI without programming, scripting languages tochange applications on fly, annotations and data-binding to accessdatabases and Web services without programming.
为了解决这些挑战,ZK给Web应用提供了桌面应用编程模型天生就具备的事件驱动、基于组件以及以服务器为中心的架构。此外,ZK提供了当前流行的UI开发技术,例如通过标志语言而不是编程来设计UI,通过脚本语言动态地改变应用,不需要编程就可以访问数据库和Web服务的注解和数据绑定。
Asdepicted above, ZK is composed of Client Engine running at the browser,and the Update Engine at the server. They act as pitcher and catcher.They work together to deliver events happening in the browser to theapplication running at the server, and update the DOM tree at thebrowser based on how components are manipulated by the application atthe server.
正如上图所描述的,ZK是由运行在浏览器上的客户端引擎组成的,而更新引擎则位于服务端。他们就像是棒球里的投手和捕手。他们一起配合,将浏览器上发生的事件提交给运行在服务器端的应用,同时根据如何在服务器端生成组件的方式,来更新浏览器的DOM树。
Atthe heart, all your application codes are running at the server.Whatever events triggered by users are automatically sent to yourapplication running at the server. Whatever you alter componentsrunning at the server are automatically updated to the visualrepresentation at the browser. The browser is only a presentation layerof applications, no data model, neither business logic should beexposed on it.
作为核心,所有的应用代码都运行在服务器端。任何时候被用户出发的时间都会被自动地发送到运行在服务器端的应用程序。在服务器端的组件发生的任何改变,都以可视化的方式显示在浏览器上。浏览器只是应用的表现层,没有数据模型,也没有业务逻辑会被暴露出来。
Sincethe application is running at the server, it could access the backendresources directly, such as databases and Web services. There is nocommunication hassle or security concern to access them across theInternet.
因为应用程序是运行在服务器端,所以它可以直接地访问后端的资源,例如数据库或者Web服务。在Internet上访问它们时毫无通信上的麻烦和安全隐患。
The best way to use Ajax is not to know its existence.
在不知道其存在的时候,才使用Ajax最好的方式。
Execution Flow执行流程
ZKClient engine sits at the browser to detect any event triggered byuser's activity such as moving mouse or changing a value. Oncedetected, it notifies Update Engine.
ZK客户端引用位于浏览器中,用于查探任何有用户活动驱动的事件,例如鼠标的移动或者修改了某个值。一旦探测到事件,它便会通知ZK更新引擎。
Uponreceiving the request from Client Engine, Update Engine updates thecontent of corresponding component, if necessary. And then, UpdateEngine notifies the application by invoking the event handlers, if any.
从客户端引擎接收到请求后,如果必要,ZK更新引擎便会更新对应组件的内容。然后,如果有事件处理器,更新引擎就会通过他们来通知应用。
Ifthe application chooses to change content of components, remove, add ormove components, Update Engine sends the new content of alteredcomponents to Client Engine. Then, Client Engine updates the DOM treeaccordingly.
如果应用选择改变组件的内容,删除、增加或者移动了组件,更新引擎将会发送新的、改变了的组件到客户端引擎上。然后,客户端引擎便会相应地更新DOM树。

Note:注意:
  • Tominimize the traffic between the client and the server, multiple eventsare sent back to the server at once if they are deferrable.
  • 为了减少客户端和服务器端的访问,如果事件可以延时,那么会把多个时间发送回服务器端。
  • Tomaximize the visual effect and responsiveness, ZK provides theso-called Client Side Action that you can execute, though optional,your own JavaScript codes at the client.
  • 为了最大化视觉效果和响应能力,ZK提供了一个所谓的客户端动作,让你可以(可选的)在客户端执行你拥有的Javascript代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值