- 作者:zhaozj
- 发表时间:2020-12-23 10:54
- 来源:未知
注意:以下并非足本翻译,只不过是笔记记录罢了。(更何况俺说普通话都不利落,怎么翻得好英文捏)
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.