




已阅读5页,还剩22页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
英 文 翻 译Flex vs. JSP介绍我是一个网络应用程序开发者. 它意味着这些天发生的很多事情但是对我而言, 它意味着我同时在服务器和客户端上编写代码以实现一个完整的应用. 对我们中的很多人来说, 客户端的代码是 JSP JavaServer Pages. 你也许像我一样发现 JSP 的语言和类型的混合使它笨拙而难用. 同时我还发现开发大型应用更加复杂 所以我加了一些包如Struts 和Tiles以便使jsp简单.几年之前我开始学习和使用Macromedia Flash 因为我读到它能够接受和发送基于HTTP协议的信息. 我将它看成一种避免使用jsp编写网络应用程序的方法. 这确实是个好主意. 然而,很明显使用Flash 使我的小组里的其他成员不能通过创建新的应用的方式容易的与我建立连接. 这是因为 Flash 存在一个急速的知识跳跃. 当商业应用并不需要太多改变的时候, 你仍然需要学习 Flash IDE 并且熟悉应用开发怎样应用 Flash. The Flash MX 版本包含 一组预先确定好的 UI 组件 (比如组合框, 列表,和按钮) 来加速网络应用开发. 即使使用最新的译本 Flash MX 2004, 仍然存在知识跳跃的问题. 例如, 建立一个一个高级应用, 你必须知道怎样用帧和时间轴的层次制作flash.有一段时间 我驱使我自己 接收我的队员必须成为flash开发者这个事实. 我的这种想法遇到一些阻力,但是看上去我没有别的选择. 我已经看过了Macromedia的新产品Flex, 并且有一段时间考虑加入版本测试工作, 单是因为我正忙于编写flash应用而未能加盟. 一次我得到了Flex的第一个版本的测试拷贝, 它改变了我对网络应用开发的看法.What is Flex?Macromedia Flex 是一种专为经由web浏览器发送到最终用户的企业水平的应用开发设计的新产品. Flex 较之 Flash有更柔和的知识转折. 它涵盖了所有的用户界面组成部分. 你开发 Flex 应用程序很大程度上像开发 JSP or HTML 应用程序. Flex 解决了我使用 Flash所遇到的问题而仍能实现我用 Flash实现的功能.如果你熟悉 JSP 技术, Flex 你将不会觉得陌生. 正想用 JSP, 服务器一边的技术用来发送信息到最终用户; 未加工的源头文件存在于服务器中 ,并且在传送的时候被服务器转变为浏览器可以执行的文件. 但是 Flex 和以前的技术有以下异同.Macromedia Flex 发送 Macromedia Flash 应用程序而不是HTML到最终用户的浏览器. The Flash player, 一个嵌入到 web 浏览器的插件程序, 执行 Flash 应用程序. 下面的图像用来展示Flex的工作过程. 注意看它与 JSP 的工作过程何其相似.Image I 1. 开发者创建 Flex 源文件.这些是包含一种称为MXML的XML味道的正文文件没有专业化的编辑或者环境要求.2. 最终用户将连接到该MXML 文件的地址输入到他们的浏览器地址栏.3. 服务器, 搜索 MXML 文件, 寻找一个相应SWF 文件. 这就是那个 Flash 应用程序.如果那个 SWF 文件不存在, 或者那个MXML 文件比那个SWF 文件更新, Flex 引擎将重新编译MXML到 一个新的SWF 文件.4. SWF 封装在一个简单 HTML 文件内(所以浏览器能执行它) 并被寄回到用户的浏览器r.浏览器装载Flash player 这个插件程序并且 执行 Flash 应用程序.当用户与 Flash 应用程序交互的时候, 信息从 Flash应用程序传到遥远的目标 或者通过 Web 服务, XML 文件, or Java Beans, 保存在服务器.Flex 制作 短小的客户端代码. 瘦客户端, 比如浏览器, 放置尽量多处理任务在服务器端. 数据确认 (这在客户端上使用javaScrip是可能实现的), 计算, 定位, 这些全都在客户端上很好的执行并让那里发挥了最大的处理能力. 使用 Flex, 客户端可以给数据分类, 安排成它们想要的格式, 打印报告, 并用一种全新的有效的而靠以前的网络技术无法实现的方式进行交互.例如: 和仅仅靠列表数据绘制图表相比. 它允许用户通过提供控制数据的界限的滑块与图进行交互. 允许用户点击专栏标题分类数据. 包含专家解释工具怎么工作,怎么与madia 服务器连接以及他人与专家的交流的短小影片. 利用便捷的控制工具, 比如刻度盘, 标尺, 米尺, 来提供实时的视觉反馈 (e.g., price-ticks).The JSP Way我使用 JSP所遇到的问题之一就是, 在一个单独的文件中可能存在混合的语言和程序设计格式. 例如:JSP tags 这些涉及到在服务器上运行的 beans, 无论是平常 Java beans 企业 Java Beans.这些标记符中的一些可能是专门为某一个工程而写并且设计的让这些底层Java 代码对于网页设计者透明.Java code 这被翻译成一个在服务器上运行的servlet, 用来制造在客户端浏览器上运行的 HTML.HTML 这是浏览器要执行的程序.JavaScript 这是客户端的浏览器要执行的代码(有代表性的就是做简单的数据确认 或修改业面上的HTML 控制).VBScript 这是客户端的浏览器要执行的代码(和 JavaScript 用法相近).JSPs 必须在多种浏览器测试确认任何JavaScript 、VBScript 还有HTML都是兼容的. 开发者必须在文件中放置许多的条件代码来说明那些不同点。要完全的分离客户端(或者用户界面) 代码和服务器端 (或者商业界面) 代码是困难的. 例如, 用 JSP编写一个在服务器端运行用来生成HTML 的Java bean是可能的. 很多的努力被投入到使 JSP 开发更容易中来. 服务器程序开发者可以为网络程序开发者创建在编写JSP文件时要用的标记符库。. 这按理有助于分离客户端代码和服务器端代码.为这个目的开发的比较常见包之一就是来自阿帕奇软件基金的Struts. Struts是利用一些软件方法来降低JSP开发的复杂性的一次尝试. 服务器程序开发者建立一组处理JSPs输入并将处理结果发送到另一些JSPs的窗体和动作; 这和写在XML中的配置文件被放置在一起.另外, 为用户界面重新使用,有同样来自阿帕奇的碎片包. 这允许一个网页被拆分成多个规则部分这些部分用配置文件记述并用JSPs执行. 虽然有这么多的努力, 你仍会发现某一个工程要一个新手去编写仍然是很困难的,要从一个新手.The Flex Way与之相比, Flex MXML 文件中的所有程序都是为客户端指定的. 不可能在其中写代码, 例如打开数据库连接和 处理结果确定都将在服务器上运行结束. 这有以下几个好处: 如同在一个模型-观看-控制器体系结构中,服务器端代码和客户端代码明确的分离.客户端程序开发者专注于表达和与最终的用户的交互. 不需要你具有包括了解客户端在内的全面的能力服务器端应用构成就能轻松编写. 使用Flex, 分工更加明确 服务器端不做服务器端操作以外的任何事情. Flex 带来了大量的有用的类来维护这个分离. 例如, 在一个 JSP 应用程序中, 代码可以为现在的用户安排日期和时间. 在 Flex中, 数据尽可能原始的到达Flash 应用程序并在客户端用它的局部处理功能进行处理 (对日期和数目来说).使用 Flex开发可以清楚的划分任务: 服务器程序开发者创建服务器程序代码,客户端开发者创建用户的代码. 两边一起遵从同样的界面和数据格式, 但是两边可以自由使用他们知道的最好的方法实现他们的部分.Sample Application这是一个小的比较JSP和Flex的例子. 两个应用程序在服务器上用了相同的 Java beans.JSP ExampleImage IICode I: employeepanel.jspEmployee ListSelect a department:EngineeringProduct ManagementMarketingNamePhoneEmail% for(int i=0; i 注意观察 (红色的) Java是怎么和HTML混在一起的.即使在这样简单的一个例子中, HTML的结构还是被Java破坏了使它难以阅读. 当程序变得更加复杂的时候, Java 代码中的一部分 将被特殊的标记符代替, 但是你可以看到它是多么容易的就被坏的编程习惯给破坏了.为了让这个程序工作, 那个 “Get Employee List” 按钮通过调用它自己 提交数据形式 (那个组合列表框). 我发现这个介绍信程序给人混乱的感觉特别是在大的工程中.FlexImage IIICode II: taken from the Flex Explorer sample supplied with the Flex installation. 这个Flex 代码 不一定比JSP的代码少,但是你会发现客户端程序是怎么在应用容器内摆放的. 远程目标连接应用程序到服务器端的Java beans. 当 “Get Employee List” 按钮 被点击时, Java bean的方法被调用.结果被数据提供者的属性有力的限制在DataGrid内. 这里没有明显的程序上的消息; 联系就是细微的方法符号的不同和他们到达时结果限制在他们的目标文件.如果你用JSP编写一个最终用户能够分类的表,你就会知道这是多么的复杂。HTML不提供任何分类表的方法。也不提供显示一张表已被分类的方法.Flex的功能强大就体现在它能够创建不依赖于服务器运行的应用程序. 例如, 要分类一个表中的数据,用户只要点击专栏标题就可以了. Flex DataGrid要比 HTML 表格强很多:它具有不需要联系服务器就能分类它的数据的能力.Flex 使开发者给应用程序添加特征变的容易,比如分类一个表格; 而使用 JSP, 这样的特征添加可能要花费几天的时间才能完成.Comparison Chart下面的图表用常见的开发问题对 JSP 和Flex 做了比较:任务JSPFlex开发实践很困难 需要很多的规定来保持数据和控制的分离. 用 JSP 很容易造成混乱并且连接数据库需要数据介绍很容易 Flex 遵循 MVC 范例. 你只需要用 Flex创建客户端应用程序; 你的服务器端代码仍然是独立的.服务器导向体系结构 (SOA)它可能从JSP应用程序创建到web服务器的连接, 这些连接从服务器上执行 因为 JSP 产生Java servlet很容易网络服务和其他远程程序消息被放入到了Flex.简便性JSP 开发者必须在多种浏览器和平台上测试, 例如, 不要总是执行相同的操作, 不是100%的和所有浏览器兼容. 这需要投入更多的质量评估时间.Flex 产生能运行世界上98% 的桌面上的 Flash 应用程序、. 它与浏览器和操作系统的兼容性意味着它需要更少的质量评估时间.用户的体验JSP 提供HTML 能够提供的全部. 但是你仍必须更新网页来加入新的内容. 例如,分类一一个表格是在服务器上进行,并发送一张新的页面.Flex 提供给用户一个丰富的体验. 应用程序部分能够一起完成这些. 多媒体和其他一些新技术将被容易的融合在一起.感官改变能够通过CSS和在单独的元素上实现.改变能够通过 CSS 也能通过 Flex style sheets实现. 改变能被实施在单独的元素, 组合的类, 或整个应用程序上. 更深一步, 成分能被重定义外表以带来一个全新的视觉效果.应用程序开发JSP 开发者能在多种语言(HTML, Java, JavaScript, 和 VBScript)混合来编写页面代码. 这将导致混乱和浏览器/操作系统兼容性问题.开发者可以创建从JSP 编辑器隐藏大部分服务器端代码的自定义标记符.Flex 开发者使用 MXML 标记符和 ActionScript. 任何文本编辑器都可以使用或者在不远的将来用一种Macromedia 专为 Flex开发的IDE.自定义成分能够扩充现有的Flex 成分或者新的东西可以从scratch创建出来.应用程序的维护依赖于 JSPs 是怎样编写的, 应用程序的维护可能会像一个噩梦.混合语言和开发技术的网页的网页不仅仅难于调试而且难于扩充 .因为 Flex 是基于XML 只用了一种开发语言, 并且单独为客户端制作编写, 所以在开发和维护方面不会有太多的问题.调试JSPs 的难于调试是众所周知的.因为产生的Java代码具有极少的与源文件的关系,寻找和修改问题是一件令人生畏的任务.Flex 带来了 Flash Debug player 一种与用来帮你实时调试代码的用户界面, 同时也让你监听服务器端和客户端的数据通信.压型不容易被利用.Flex 带来了 profiler .它让你能够发现执行的瓶颈.Not a Panacea就像 Flex,JSP同样有它的优势. 我认为 Flex 适合于做应用程序开发 而 JSP 适合于做网站开发. 例如, Flash Player 就不适合于提供大量的HTML 文本因为它必须画出矢量图作为的每一个特性.Macromedia 已经在Flex 包中放入了一个 JSP 标记符库,它能让你将你的Flex 应用程序放入到网页中. Ironically, 你能够使用你的 Flex 标记符库在传输过程中产生MXML, 就像 HTML那样!一定要记住, Flex 和JSP 能够友好共存.ConclusionJSPs 仍会被使用, 使用Flex 开发应用程序所引起的影响将是巨大的. 不光用户会有一个更好的更丰富的体验, 应用程序开发者同样会有.通过允许服务器应用程序开发者创建服务器端, 使他们摆脱了客户端程序开发者身份,他们的工作更加容易更加专业化. 同样的, 客户端程序开发者能够全神贯注于给最终用户开发出更加有效更加丰富的应用程序.人们认为 JSPs 曾经就是这样的新技术,事实上它被用来制作网络上的动态内容. 我认为 Flex是基于网络的应用程序开发的下一个方向. Flex 通过更容易开发和维护的方法带给了网络更丰富的应用从而确立了这个方向.用 Flex的投资收益要比用JSP的大 (Java applets) ,因为大量的时间被划给在了开发有用的应用程序而不是解决兼容性问题.ResourcesFlex 应用程序的例子, 访问我的网站 /flex. 这里还有一些涉及到更深入的阅读材料:Macromedia Flex 产品介绍:/software/flex/Macromedia Flash Player 分布状态:/software/player_census/flashplayer/最好的用 Flex开发应用程序的惯例:/devnet/flex/best_practices.html Flex 性能摘要: Flex 和 JavaServer Pages 应用程序比较: 2004年5月./devnet/flex/articles/performance_brief.html?trackingid=devcenterupdate_email_060204Flex vs. JSPIntroductionI am a web application developer. That can mean a number of things these days, but in my case, it means I write code on both the client and the server to make a complete “application”. For many of us, the client side code is JSP JavaServer Pages. Perhaps, like me, you find JSP to be awkward with its mixture of languages and styles. I also find developing large applications to be ever more complex as I add packages such as Struts and Tiles, which are intended to make using JSP easier.A few years ago I started to learn and use Macromedia Flash because I read it had the ability to send and receive information via HTTP. I saw Flash as a way to avoid using JSP to write web applications. This turned out to be a good idea. However, it quickly became obvious that using Flash was not going to enable the other members of my group to easily join me in creating a new generation of applications. This is because Flash has a steep learning curve. While most business-like applications do not require animation, you still have to learn the Flash IDE and become familiar with how application development is done with Flash. The Flash MX release included a set of predefined UI components (such as combo-boxes, lists, and buttons) to speed application development. Even with the newest version, Flash MX 2004, there is still a learning curve issue. For instance, to build a respectable application, you have to understand how Flash movies are produced with their layers of movie clips and timelines.For a while I resigned myself to the fact that my team members may have to become Flash developers. I met some resistance with this idea, but there did not seem to be any alternatives. I had been reading about Macromedias new product, Flex, and for a while considered joining the beta effort, but I was too busy writing Flash applications to take part. Once I got a trial copy of the first release, Flex changed how I view web application development.What is Flex?Macromedia Flex is a new product designed for the development of Enterprise-level applications that are delivered to end-users via web browsers. Flex has a much softer learning curve than Flash. It comes chock-full of user interface components. You develop your Flex applications much the same way you develop JSP or HTML applications. Flex solves the problems I had using Flash while still delivering on the promise I saw with Flash.If you are familiar with JSP technology, Flex will not seem too dissimilar. Just as with JSP, server-side technologies are employed to deliver information to the end-user; raw “source” files exist on a server and are converted on the fly by server-side components into a form presentable by a browser. But the similarities between Flex and previous technologies end there.Macromedia Flex delivers Macromedia Flash applications, not HTML, to the end-users browser. The Flash player, a plug-in to the web browser, renders the Flash application. Image I shows the Flex process in detail. Notice how similar it is to how JSP operates.Image I 5. The developer creates Flex source files. These are text files that contain a flavor of XML known as MXML. No specialized editors or environments are required.6. The end-user enters the URL to this MXML document into their browsers address bar.7. The server, detecting the MXML extension, looks for a corresponding SWF file. This is the Flash application.If the SWF file does not exist, or if the MXML file is more recent than the SWF file, the Flex engine recompiles the MXML into a new SWF file.8. The SWF file is packaged within a simple HTML wrapper (so the browser can display it) and sent back to the users browser.The browser loads the Flash player plug-in and displays the Flash application.As the user interacts with the Flash application, calls are made from the Flash application to remote objects either via Web Services, XML documents, or Java Beans, residing on servers.Flex produces “smart client” code. Thin clients, such as web browsers, place most of the processing duties on the server. Data validation (which is possible with JavaScript on the client), calculations, localization, and such are best done at the clients computer and make the most of the processing power there. With Flex, the client can sort their data, have it formatted to their liking, print reports, and interact in new and meaningful ways that were not possible with previous web technologies.Examples: Rather than simply list data values, draw a graph. Allow the user to interact with the graph by providing sliders that control the bounds of the data. Allow the user to click on column headings to sort the data. Include short movie clips of experts explaining how tools work or connect to media servers and chat live (video and audio) with the expert. Use animated controls, such as dials, gauges, and meters, to provide visual feedback of real-time events (e.g., price-ticks).The JSP WayOne of the issues I have with JSP, is that it is possible to have a single file that contains a mixture of languages and programming styles. For example:JSP tags these refer to beans that execute on the server, be they plain Java beans or Enterprise Java Beans. Some of these tags may be specially written for a project and are designed to mask the underlying Java code from a web page designer.Java code this is translated into a servlet that executes on the server, producing HTML to be rendered by the clients browser.HTML this is rendered by the clients browser.JavaScript this is code executed by the clients browser (typically to do simple data validation or modify the HTML controls on the page).VBScript this is code executed by the clients browser (in a similar way JavaScript is used).JSPs must be tested on a variety of browsers to make sure any JavaScript or VBScript, as well as HTML, is compatible. Developers often have to place a lot of conditional code within the files to account for the differences.It is hard to have a clean separation of client-side (or user interface) code from server-side (or business) code. For example, it is possible with JSP to write a Java bean that produces HTML in the course of executing business logic. A lot of effort has been put into making JSP development more palatable. Business logic developers can create tag libraries for web developers to use when coding JSP files. This supposedly helps separate the user interface code from the business logic code.One of the more common packages developed for this purpose is Struts from the Apache Software Foundation. Struts is an attempt to apply some software methodologies to the complexity of JSP development. The business logic developers create a series of forms and actions which process input from the JSPs and forward the results to other JSPs; this is put together with configuration files written in XML.In addition, for user interface code re-use, there is the Tiles package, also from Apache. This allows a web page to be broken into rectangular sections (“tiles”) described by configuration files and implemented with JSPs. Nonetheless, with all of this effort, you can create pretzel-logic web code that can be difficult for project newcomers to untangle.The Flex WayBy contrast, all of the code within a Flex MXML file is destined for the client. It is not possible to write code, such as opening database connections and processing result sets that would wind up running on the server. There are several benefits to this: There is a clear separation of client/side and server/side code as in a Model-View-Controller architecture. The user interface developer concentrates on presentation and interaction with the end-user. Server-side components of the application are cleanly written without the possibility of doing anything that
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年民航博物馆招聘考前自测高频考点模拟试题附答案详解(完整版)
- 2025内蒙古自治区农牧业科学院招聘48人考前自测高频考点模拟试题及答案详解(新)
- 2025吉林大学白求恩第一医院中医科医生招聘1人考前自测高频考点模拟试题及答案详解(夺冠系列)
- 2025年泰和县上圯水厂面向社会公开招聘模拟试卷附答案详解(考试直接用)
- 传统村落保护利用及高效农业设施项目施工方案
- 市政管道工程项目风险评估与管控方案
- 城市照明管控与维护方案
- 2025内蒙古金土华维可控农业科技有限公司招聘9名工作人员考前自测高频考点模拟试题及答案详解参考
- 2025年甘肃省庆阳市镇原县第二批城镇公益性岗位83人考前自测高频考点模拟试题带答案详解
- 2025鄂尔多斯市育知人才开发服务有限公司招聘辅助性审计服务项目工作人员5人模拟试卷及答案详解一套
- 粉红税问题成因分析
- 知识产权转化与产权运作制度
- 中国冠心病康复循证实践指南(2024版)解读
- 部编版历史八年级上册第一单元 第2课《第二次鸦片战争》检测卷(后附答案及解析)
- 《北京市二年级上学期数学第二单元试卷》
- 中国老年患者术后谵妄防治专家共识2023
- 山东省济南市舜耕中学2024-2025学年九年级上学期10月月考化学试题(无答案)
- 明股实债合作完整协议
- 2024年“蓉漂人才荟”四川成都市农林科学院招聘高层次人才8人历年【重点基础提升】模拟试题(共500题)附带答案详解
- 厦门航空港货运业务竞争战略研究的中期报告
- 设计伦理与社会责任
评论
0/150
提交评论