瞎看看Tapestry

 

注意:以下并非足本翻译,只不过是笔记记录罢了。(更何况俺说普通话都不利落,怎么翻得好英文捏)

An overview of Tapestry

瞎看看Tapestry

Perhaps the hardest part of understanding Tapestry is the fact that it is component-centric not operation-centric. Most web technologies (Struts, servlets, PHP, etc.) are operation-centric. You create servlets (or Actions, or what have you) that are invoked when a user clicks a link or submits a form. You are responsible for selecting an appropriate URL, and the name and type of any query parameters, so that you can pass along the information you need in the URL.

可能最难理解的部分,Tapestry实际上面向组件而不是面向操作,大多数的网页技术(……)是面向操作的。你可以创建一个servlet(或者Actions,或你手头正干着的东西),当用户点击一个链接或提交一个表单的时候将会调用他们。你需负责选择一个适当的URL,合适的名称、类型,因此你才能继续传递从URL得到的信息。

You are also responsible for connecting your output pages (whether they are JSPs, Velocity templates, or some other form of templating technology) to those operations. This requires you to construct those URLs and get them into the href attribute of your <a> tag, or into the action attribute of your <form> tag.

你还需负责连接你的输出页面(jsp或者Velocity反正是模板的东东)到这些操作。这需要你构建一些URL然后把它们放在超链标记里面。或放在form标记的action属性中。

Everything is different inside Tapestry. Tapestry applications consist of pages; pages are constructed from smaller components. Components may themselves be constructed from other components. Every page has a unique name, and every component within a page has its own unique id ... this is a component object model. Effectively, every component has an address that can easily be incorporated into a URL.

在Tapestry中,所有的事情变得不同了。Tapestry应用由页面组成;页面由更小的组件构成。组件可能由其他组件构成。每个页面有一个唯一的名字,而每个组件在一个页面中有着其唯一的标识,这是一个组件对象模型。每个组件有一个地址可以轻易地拼装组成到URL中。


In practical terms, your don't write a servlet for the add-item-to-shopping-cart operation. In fact, you don't even write an add-item-to-shopping-cart component. What you do is take an existing component, such as DirectLink, and configure it. When the component renders, it will create a callback URL. When you click that link, the callback URL (which includes the name of the page and the id of the component within the page) will invoke a method on the component ... and that method invokes your application-specific listener method. [1] You supply just the listener method ... not an entire servlet. Tapestry takes care that your listener method is invoked at the right time, under the right conditions. You don't have to think about how to build that URL, what data goes in the URL, or how to hook it up to your application-specific code--that's all handled by the framework.

在有经验的团队里,你不会为add-item-to-shopping-cart操作写一个servlet。事实上,你甚至不需要写一个add-item-to-shopping-cart组件。你不该干这些破事。选一个已经存在的组件并配置一下,像DirectLink。当它发挥作用的时候,它会创建一个callback URL。当你点这个连接,这个回调URL(包含了页面名称以及页面中的组件标识)将会调用组件中的方法……而这个方法调用你的应用明确的侦听者方法(鬼知道它讲什么,继续翻)。你只需要提供一个侦听者方法,而不是一个实际的servlet。Tapestry关心的是在正确的时间,正确的情况下调用你的侦听者方法,你不必再想怎么构造URL,该往URL放啥数据,或者怎么跟你的应用代码勾搭上--这些都在框架的掌控之下啦。哇哈哈哈哈……(随意增加语句,该死)


Tapestry uses a component object model to dispatch incoming requests to the correct page and component.

Tapestry用组件对象模型转发请求至正确的页面、组件

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值