码迷,mamicode.com
首页 > 其他好文 > 详细

Meet Apache Wicket

时间:2014-06-29 22:57:45      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   

刚开始接触Wicket,所以很多内容都是直译,把原文贴上,望大家指正


Meet Apache Wicket

    By JonathanLocke, original author of Wicket

    乔纳森·洛克,Wicket的原作者

Why Wicket?

 

    If you arelooking to do web application programming in Java, you have a very large numberof choices these days. In fact, there are so many web application frameworksnow that it has become somewhat of a joke. One blog site on the Internet posesthe question: How many Java web frameworks can you name? The answer they showlooks like this:

    如果你打算做 Web应用程序的编程用java,如今你有非常多的选择。事实上,有这么多的Web应用程序框架现在它已经变得多少有点可笑了。一个网上的博客里提出了一个问题:有多少的JavaWeb框架你可以说出来?他们的答案是这样的:

Frameworks, Frameworks Everywhere

Echo

Cocoon

Millstone

OXF

Struts

SOFIA

Tapestry

WebWork

RIFE

Spring MVC

Canyamo

Maverick

JPublish

JATO

Folium

Jucas

Verge

Niggle

Bishop

Barracuda

Action Framework

Shocks

TeaServlet

wingS

Expresso

Bento

jStatemachine

jZonic

OpenEmcee

Turbine

Scope

Warfare

JWAA

Jaffa

Jacquard

Macaw

Smile

MyFaces

Chiba

JBanana

Jeenius

JWarp

Genie

Melati

Dovetail

Cameleon

JFormular

Xoplon

Japple

Helma

Dinamica

WebOnSwing

Nacho

Cassandra

Baritus

Stripes

Click

GWT

 

 


Why Reinvent the Wheel?

    为什么要“推倒重来”

    In light ofthis, you may be wondering What good isanother web application framework? Indeed. Why re-invent the wheel? One snappy comeback to that old saw is: because this time we couldmake it rounder!

    But it was notsimply a desire for higher quality that drove the creation of Wicket. Even withso many options, there really is no web toolkit which fills exactly the nichethat Wicket fills. In fact, Wicket is quite unlike each of the frameworksabove.

Wickets closest cousins are probably Tapestry andEcho, but even there the likeness is very shallow. Like Tapestry, Wicket uses aspecial HTML attribute to denote components, enabling easy editing withordinary HTML editors. Like Echo, Wicket has a first-class component model. ButWicket applications are not like applications written in either Tapestry orEcho, because in Wicket you get the best of both worlds. You get the benefitsof a first-class component model and a non-intrusive approach to HTML. In manysituations, this combination may prove to be a significant developmentadvantage.

    To understandwhy Wicket is so different, it may help to understand the motivations thatcreated it.

    鉴于这一点,你可能会想“另一种Web应用框架有什么好处呢?”的确如此。为什么要“推到重来呢?”这让我想起来一个老话:因为我们可以做的更完美!

    但它为更高质量的实现并不是创造wicket的唯一动机。即使有这么多的选择,但是并没有一个web工具能完全符合wicket文件。事实上,Wicket的是完全不同于上述各框架。

    Wicket的最亲密的表兄弟可能是Tapestry和Echo,但即使有想象的地方也是很少的。像Tapestry ,Wicket使用一种特殊的HTML属性来表示的元件,可以方便编辑与普通的HTML编辑器。像Echo,Wicket拥有一流的组件模型。但Wicket的应用程序并不像写在任的Tapestry或Echo的应用,因为在Wicket里你可以两全其美。你可以同时在第一级的部件模型和非侵入式方法的HTML中的好处。在许多情况下,这种组合可能被证明有显著发展优势。

 

    要理解为什么Wicket的是如此的不同,它可能有助于了解创建它的动机。

 

Motivations

 Most existingweb frameworks provide weak to non-existent support in managing server-sidestate

大多数存在的web框架提供几乎不存在的管理服务端状态的支持

    This normallymeans lots of ad-hoc code in web applications dealing with the gory mechanicsof state management. While Wicket will not allow you to stop thinking aboutserver state, it goes a long ways towards making it easy and often transparentto manage that state.

   In Wicket, allserver side state is automatically managed. You will never directly use anHttpSession object or similar wrapper to store state. Instead, state isassociated with components. Each server-side page component holds a nestedhierarchy of stateful components, where each components model is, in the end, a POJO (Plain OldJava Object). Wicket maintains a map of these pages in each users session. One purpose of this page map(and the component hierarchy on each page) is to allow the framework to hideall details of how your components and models are accessed. You deal withsimple, familiar Java objects and Wicket deals with things like URLs, sessionids and GET/POST requests.

    通常,这意味着大量的专门的代码在Web应用程序处理状态管理。而Wicket不会让你停止关于服务器状态的思考,他在朝着使用更容易更透明化管理的方向上经过了一个漫长的道路。

    在Wicket中,所有的服务器端的状态会自动进行管理。你将永远不会直接使用HttpSession对象或类似的包装器来存储状态。相反,状态与组件相关联。每个服务器端页面组件保存有一个嵌套层次的有状态组件,每个组件的模型的最后是一个POJO(普通的Java对象)。Wicket包含这些页面的地图中每个用户的会话。这个页的映射(每个页面上的组件层次结构)的目的之一是让框架隐藏了如何将组件和模型访问的所有细节。你只需要处理简单、熟悉的Java对象,Wicket处理的事情,比如URLs,session ID和GET/POST请求。

 

    You will alsofind that this well-structured server state makes it very easy to deal with thedreaded back buttonproblem. In fact,Wicket has a generic and robust solution which can identify and expirebrowser-cached pages that have become stale due to structural changes to themodel of a component on the page.

    Finally, Wickethas been designed to work with POJO persistence frameworks such as JDO orHibernate. This can make database driven web applications quite easy to write.

    For manyapplications, it will be worth trading off the increased server load of extraserver-side state for decreased development costs, lower maintenance costs,quicker time-to-market and generally higher quality software. The basicobservation here is that software is expensive and complex while servers fromcompanies like E-machines and Dell are relatively dirt cheap.

    In terms ofefficiency versus productivity, perhaps Wicket is to JSP as Java is to C. Youcan accomplish anything in Wicket in JSP. You may even do it more efficientlyin terms of memory or processor consumption. But it may take you weeks ormonths longer to develop your application. And in the end, since state managementin JSP is ad-hoc, you are likely find security problems and bugs popping upeverywhere. Most of the other frameworks above will do only a little more tohelp you.

    你还会发现,这个结构良好的服务器状态使得它很容易对付可怕的“后退按钮的问题”。事实上,Wicket有一个通用的和强大的解决方案,它可以识别和过期的浏览器缓存页面已经陈旧由于对页面上的一个组件模型的结构变化。。

    最后,Wicket已被设计为与POJO持久性框架如Hibernate或者JDO。这可以使数据库驱动的Web应用程序更容易实现。

对于许多应用程序,这将是一笔值得的交易,去增加额外的服务器端状态,降低开发成本,降低维修成本,缩短上市时间,实现更高质量的软件。这里的基本看法是,软件是昂贵和复杂的e-machines和戴尔公司的服务器是相对便宜的。

    在效率与生产力方面,或许Wicket对于JSP的关系就想Java对于C一样。您可以在Wicket中在JSP中完成任何事情。你甚至可以更有效地做到这一点的内存或处理器??消耗方面。但它可能需要你几个星期甚至几个月更长的时间来开发应用程序。而在最后,因为状态管理在JSP是临时的,你很可能发现的安全问题和错误遍地开花。最上面的其他框架对你的帮助只能是微乎其微。

 

 

Most existingframeworks require special HTML code

大多数现有的框架需要特殊的HTML代码

    JSP is by farthe worst offender, allowing the embedding of Java code directly in web pages,but to some degree almost all of the frameworks from the list (except Tapestry)above introduce some kind of special syntax to your HTML code.

   JSP是迄今为止最严重的错误,就是允许直接在网页中的Java代码嵌入,但在一定程度上几乎所有的框架(除Tapestry)在列表上面介绍某种特殊的语法来你的HTML代码。

 

   Special syntaxis highly undesirable because it changes the nature of HTML from the kind ofpure-and-simple HTML markup that web designers are familiar with, to some kindof special HTML. This special HTML can be more difficult to preview, edit andunderstand.

    特殊的语法是极不可取,因为它把HTML自然纯净而简单的那种网络设计是特别熟悉的HTML标记,转换成对一些特殊的HTML。这种特殊的HTML是更预览编辑和理解的。

    Wicket does notintroduce any special syntax to HTML. Instead, it extends HTML in astandards-compliant way via a Wicket namespace that is fully compliant with theXHTML standard. This means that you can use Macromedia Dreamweaver, MicrosoftFront Page, Word, Adobe Go Live, or any other existing HTML editor to work onyour web pages and Wicket components. To accomplish this, Wicket consistentlyuses a single id attribute in the Wicket namespace (wicket:id) to mark HTMLtags that should receive special treatment by the toolkit. If you prefer not torender Wicket namespaced tags and attributes to your end-users, Wicket has asimple setting to strip them all out, resulting in ordinary,standards-compliant HTML.

    Wicket不引入任何特殊的语法为HTML。相反,它通过是完全符合XHTML标准一个Wicket命名空间扩展的HTML标准兼容的方式。这意味着你可以使用Macromedia的Dreamweaver,Microsoft FrontPage, Word, Adobe Go Live,或任何其他现有的HTML编辑器工作在您的网页和Wicket组件。要做到这一点,Wicket一贯使用的Wicket命名空间中的单个id属性(“Wicket:ID”)来标记应接受特殊处理的工具包的HTML标签。如果你不喜欢渲染Wicket命名空间的标签和属性到您的终端,Wicket有一个简单的设置使我们都脱离他们,实现一个普通的,符合标准的HTML。

    No special sauce in your HTMLmeans designers can mock up pages that you can use directly in development.Adding Java components to the HTML is as simple as setting the component nameattribute. And you can then give the HTML back to your web designers knowingthat they can change it with confidence.

    没有“调料”在你的HTML意味着设计师模拟的页面,可以直接在程序中使用。添加Java组件到HTML想设置组件的名字属性一样简单。然后把HTML返回到网页设计师那里并且让他们知道改变网页是一件很容易的事情。

 

    Wicket, more thanany other framework gives you a separation of concerns. Web designers can workon the HTML with very little knowledge of the application code (they cannotremove the component name tags and they cannot arbitrarily change the nestingof components, but anything else goes). Likewise, coders can work on the Javacomponents that attach to the HTML without concerning themselves with what agiven page looks like. By not stepping on each others toes, everyone can get more work done.

    Wicket,比其他任何框架更容易实现分层。网站设计者用很少的应用代码的知识只是去操作HTML(他们无法删除的组件名称标签,他们不能随意更改组件,其他的都可以)。同样,编码器可以工作在Java组件连接到HTML不关心什么一个给定的页面。只要不踩其他人的脚趾头,每个人都可以做更多的工作。

 

Existingframeworks are not easy

现有的框架都不是简单的

    Most of theexisting toolkits have poorly defined or non-existent object models. In somecases, the model is defined using special XML syntaxes. The syntaxes may be socumbersome that special tools are required to manipulate all the configurationinformation. Since these toolkits are not simple Java libraries you may or maynot be able to use your favorite IDE tools such as editors, debuggers andcompilers.

    Wicket is allabout simplicity. There are no configuration files to learn in Wicket. Wicketis a simple class library with a consistent approach to component structure. InWicket, your web applications will more closely resemble a Swing applicationthan a JSP application. If you know Java (and especially if you know Swing),you already know a lot about Wicket.

    大多数现有的工具包都定义不清或不存在的对象模型。在某些情况下,该模型是使用特殊的XML语法来定义。该语法可能是这样繁琐的特殊工具来操作所有的配置信息。由于这些工具包是不是简单的Java库,你可能会或可能无法使用您喜欢的IDE工具,如编辑器,调试器和编译器。

    Wicket是简单并且有没有配置文件。 Wicket的是一个简单的类库,用一致的方法来组成结构。在Wicket中,你的Web应用程序会更接近于比JSP应用程序Swing应用程序。如果你知道的Java(特别是如果你知道Swing),你已经知道了很多关于Wicket。

 

Existingframeworks inhibit reusability

现有的框架复用性不好

    Tapestry and JSFat least have component models that allow reuse, but you are likely to findthat it is not particularly trivial to do, at least when compared with Wicket.Wicket has been explicitly designed to make it very, very easy to createreusable components. Its surprisinglysimple to extend existing components and to make compound components such as aSignInPanel or AddressForm. It is also relatively easy to create componentsthat exploit new features of browsers. Components in Wicket can be packaged upin JAR files and reused by simply dropping them in your lib folder - noconfiguration necessary!

    Tapestry和JSF至少有组件模型,允许重用,但你很可能会发现,这是不是特别容易做到,至少在Wicket相比。Wicket已经被明确设计,使其非常、非常容易地创建可重用的组件。这是令人惊讶的简单扩展现有的组件和使复合组件,如SignInPanel或为AddressForm。它也是相对容易地创建利用浏览器的新功能部件。在Wicket组件可以被打包成JAR文件,并通过简单的拖放在你的lib文件夹重复使用 - 无需进行必要的配置!

Web programmingshould be fun!

Web编程应该是乐趣无穷!

    This is my mostpersonal goal for writing Wicket . None of the existing frameworks areappealing to me in terms of intuitiveness, quickness, ease of development, etc.It is my hope that Wicket represents a significant step in the direction ofmaking web applications easy and fun to write.

    Web变成是有趣的——这是我写的Wicket最个人的目标。现有的框架没有一个能够吸引我的眼球,我希望有一个可以进行直观的,快速的,易于开发的框架,Wicket使Web应用程序更容易有有趣的去实现!

Meet Apache Wicket,布布扣,bubuko.com

Meet Apache Wicket

标签:des   style   blog   http   java   color   

原文地址:http://blog.csdn.net/laner0515/article/details/35558351

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!