??xml version="1.0" encoding="utf-8" standalone="yes"?>国产成人av一区二区三区在线观看
,999国产精品永久免费视频app,久久五月天婷婷 http://www.aygfsteel.com/usherlight/category/38735.html天^׃白云泉,云自无心水自闌Ӏ何必奔冲山下去Q更LL向人间Q?/description>zh-cn Tue, 29 Mar 2011 08:15:20 GMT Tue, 29 Mar 2011 08:15:20 GMT 60 Tapestry5 in actionQmanning)的第一章免贚w?/title> http://www.aygfsteel.com/usherlight/archive/2011/03/29/347159.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 28 Mar 2011 21:53:00 GMT http://www.aygfsteel.com/usherlight/archive/2011/03/29/347159.html http://www.aygfsteel.com/usherlight/comments/347159.html http://www.aygfsteel.com/usherlight/archive/2011/03/29/347159.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/347159.html http://www.aygfsteel.com/usherlight/services/trackbacks/347159.html
Tapestry5 in action现在q只是提供MEAP形式的订购,MEAP-Manning Early Access Program, 也就是提前试阅的意思,如果读者订购了此版本,那么manning会在作者每完成一章后Q将该章节发l订购者,订购者可以提交自q反馈Qmanning会根据情况发布相应的错误修改信息?/div>
目前此书的第一章可以免费下载:
http://www.aygfsteel.com/Files/usherlight/Tapestry5%20in%20action%20MEAP%20ch01.zip
]]> Tapestry的一些最新动?/title> http://www.aygfsteel.com/usherlight/archive/2010/11/24/338872.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 23 Nov 2010 22:08:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/11/24/338872.html http://www.aygfsteel.com/usherlight/comments/338872.html http://www.aygfsteel.com/usherlight/archive/2010/11/24/338872.html#Feedback 3 http://www.aygfsteel.com/usherlight/comments/commentRss/338872.html http://www.aygfsteel.com/usherlight/services/trackbacks/338872.html
1、Tapestry5.2.4的发布,Tapestry5.2.3版本在内部投中被否冻I主要是因Z用maven快速创建的原型有问题)Q所以在被否决的3天后便发布了5.2.4,相对5.2.2来说Q变动ƈ不大Q只?个错误修复和5个功能改q。但是至说明Tapestry的项目还在顺利的q行中?br />
2、Tapestry主页的全新改版。主要是完善了文档。这一Ҏ非常重要的,Tapestry目l的成员也承认Tapestry在推销自己或者是在市场推q方面做得非常失?very bad in marketing)Q所以最q也采取了一些措施来q行改变Q比如,预计明年会发行Tapestry5 in action一书等{?br />
3、还有一件事需要提及的是:appfuse的作者最q对web框架q行了一番对比http://raibledesigns.com/rd/entry/my_comparing_jvm_web_frameworksQTapestry?3个框架中名列W?Q刚好是中间的位|。Tapestry目的成员颇有不满,认ؓ作者Matt Raible对Tapestry不够了解Q有误导观众之嫌。Tapestry目成员Igor E. Poteryaev认ؓMatt?认识度,开发效率,目健康度,试友好性,scalability{方面严重低CTapestry的能力?br /> ]]> Tapestry5.2.2(Beta Release)发布?/title> http://www.aygfsteel.com/usherlight/archive/2010/11/02/336747.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 01 Nov 2010 23:58:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/11/02/336747.html http://www.aygfsteel.com/usherlight/comments/336747.html http://www.aygfsteel.com/usherlight/archive/2010/11/02/336747.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/336747.html http://www.aygfsteel.com/usherlight/services/trackbacks/336747.html
q主要是便于ajax的用?br />
Bug
* Element.forceAttribute uses the element's namespace to match the attribute.
* Element.attribute(String name, String value) adds elements that already exist
* Element#addClassName can create an additional new 'class' attribute
* Properties defined in an Interface are not exposed by PropertyAccess for abstract classes that do not directly implement the methods
* Some services require a notification that they have been reloaded, so they can clean up external dependencies
* Whitespaces in SymbolConstants.SUPPORTED_LOCALES cause that locales are not persised
* Validation macros do not work when used in @Validate annotation
* Client-side validation of @Pattern is broken
* Linking a Form to a Zone will no longer work unless the Form contains validated fields
* When using PropertyShadowBuilder to build a service, if the property is null, an immediate exception is needed (rather than a NullPointerException)
* When using a MultiZoneUpdate, Tapestry will clear the referenced zone
Improvement
* Add the facility to optionally disable on-focus-change triggered validation while retaining the on-form-submit validation
* Form component should be able to render a secure URL even on an insecure page
* New annotations @Decorate and @Advise to identify methods that decorate or annotate services
* Extend Link with new methods for producing absolute URLs (that include scheme, hostname, etc.)
* Simplify connecting a link or form to an (enclosing) Zone
* BeanBlockContribution should be split into two sub-classes: EditBlockContribution and DisplayBlockContribution
* Define a special CSS class to prevent a client-side form from submitting normally (for Ajax use cases)
* Additional method for Link: addParameterValue(String,Object) that uses ContextPathEncoder to encode object value to a string
* SeleniumTestCase should expose the underlying CommandProcessor, to allow execution of commands not defined by the Selenium interface
* Allow individual SeleniumTestCases to run w/o configuring SeleniumLauncher
]]> Tapestry5.2.1 Beta已经发布 http://www.aygfsteel.com/usherlight/archive/2010/10/20/335644.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 19 Oct 2010 23:38:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/10/20/335644.html http://www.aygfsteel.com/usherlight/comments/335644.html http://www.aygfsteel.com/usherlight/archive/2010/10/20/335644.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/335644.html http://www.aygfsteel.com/usherlight/services/trackbacks/335644.html 今天在网上{了{Q发现Tapestry又有了新动作?br />
1、从5.2.0alpha??1日发布到现在Q终于发?.2.1Beta版了。这个版本主要是修改alpha版本中的bug.
5.2相对?.1q行了许多重大的改进Q详l内容可见:Tapestry5.2的新变化
2、据U在5.3版中引入大量的新功能,具体内容不详?br />
3、以往最令h诟病的文档问题,目前开发小l也在努力解冟?br />
首先Q徏立了新的文档|页Qhttp://people.apache.org/~uli/tapestry-site/Q不q目前这个网站还没有完全完成Q只能算是预览版Q但是这毕竟是在正确的道路上前进?br />
其次QTapestry 5 in action一书正在写作中Q已l完?0%Q预计明q一季度能够出版?br />
我相信,随着功能的不断完善和补充Q再加上文档的逐渐充实QTapestry完全有理p吸引更多的开发者来x和用?/p> ]]> Tapestry5.2的新变化 http://www.aygfsteel.com/usherlight/archive/2010/08/18/329170.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 17 Aug 2010 23:13:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/08/18/329170.html http://www.aygfsteel.com/usherlight/comments/329170.html http://www.aygfsteel.com/usherlight/archive/2010/08/18/329170.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/329170.html http://www.aygfsteel.com/usherlight/services/trackbacks/329170.html
1、增Zclass reload的功能(我个Z认ؓq一Ҏ5.2版本最令hȀ动的改进Q,以前Tapestry和其他的web框架cMQ修攚w面不需要重新启动application server, 但是修改了类之后Q必重新启动应用服务器才行。但是在Tapestry5.2中,对这一点进行了修改Q如果只改变了接口的实现c,而不改变接口的方法签名,׃需要重新启动应用服务器
2、新增了若干个组Ӟ比如QError和Trigger?br />
Error和原有的ErrorscMQ但是Error用于l指定的lg昄验证错误信息?br />
Trigger提供了在L面q程中触发Q务事件的功能Q常常用于通过RenderSupport来给面dJavaScript代码
3、新的插?Mixin),包括RenderClientId, RenderNotification
4、集成了JSR-303 Bean的验证,现在可以在页面中使用JSR-303标准的注解来l字D|定需要的验证
5、新的注解,包括@Contribute,@RequestParameter, @ActivationRequestParameter, 使用后两个注解能很容易地获取request中的参数
6、新的页面生命周期事ӞpageReset
7、链接修饰过E中的新事g: decoratePageRenderLink, decoreateComponentEventLink
8、页面解析器的更换,原来使用StAXQ造成了对Google App Engine和对OSGI的不兼容Q?.2版本中用了标准的SAX解析?br />
9、页面缓冲池的废除(我认?.2版本的一个相当大而且也是非常重要的一个变化,我认为页面缓冲池技术是tapestry学习曲线陡峭的一个重要原因)Q?.2版本中所有页面将只有一个实例(也就是lewis howard说的单例化)Q页面属性的值将会在每个U程中用一个Map来保存。这样一个页面实例可以在多个U程中用,而不会有同步问题?br />
但是Q由于这是一个新的尝试,所以lewis也不定q样做的效果是否很好Q详见:http://tapestryjava.blogspot.com/2010/07/everyone-out-of-pool-tapestry-goes.htmlQ所以,?.2中可以通过配置恢复面~冲池的使用?img src ="http://www.aygfsteel.com/usherlight/aggbug/329170.html" width = "1" height = "1" /> ]]> prototype版的table filter http://www.aygfsteel.com/usherlight/archive/2010/07/28/327294.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 28 Jul 2010 03:02:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/07/28/327294.html http://www.aygfsteel.com/usherlight/comments/327294.html http://www.aygfsteel.com/usherlight/archive/2010/07/28/327294.html#Feedback 1 http://www.aygfsteel.com/usherlight/comments/commentRss/327294.html http://www.aygfsteel.com/usherlight/services/trackbacks/327294.html jquery有一个很方便的插件UI Table Filter可以Ҏ输入的内定w藏显Cg相应的数据行?br />
因ؓ目前使用的tapestry捆绑的是prototypeQ所以就自己写了一个类似的插g?/p>
<html>
<head>
<script src="prototype-1.6.0.2.js" type="text/javascript"></script>
<script language="javaScript">
Event.observe(window, 'load', function() {
Event.observe('filter', 'keyup', filterTable);
});
function filterTable() {
var filterCaseElement = document.getElementById('filterCase');
var caseSensitive = filterCaseElement.checked;
$$('tr').each(function(trElement, ind) {
var val = $('filter').value;
if ( ! caseSensitive ) {
val = val.toLowerCase();
}
trElement.childElements().each(function(tdElememt) {
var tdText = tdElement.innerText;
if ( ! caseSensitive ) {
tdText = tdText.toLowerCase();
}
if (tdText.include(val)) {
trElement.show();
} else if ( ind > 0 ) {
trElement.hide();
}
});
});
}
</script>
</head>
<body>
filter: <input type="text" id="filter" name="filter"/> <input type="checkbox" id="filterCase" onchange="javaScript:filterTable();"/> Case-Sensitive
<table border="1">
<thead>
<tr>
<th>name</th>
<th>column1</th>
<th>column2</th>
<th>column3</th>
<th>column4</th>
<th>column5</th>
<th>column6</th>
</tr>
</thead>
<tr>
<td>TEST</td>
<td>00150002331</td>
<td>238156</td>
<td>075</td>
<td>001</td>
<td>172.16.14.20</td>
<td>1-1-05</td>
</tr>
<tr>
<td>TEST-2</td>
<td>00150002332</td>
<td>238157</td>
<td>075</td>
<td>002</td>
<td>172.16.14.21</td>
<td>1-1-05</td>
</tr>
<tr>
<td>TEST</td>
<td>00150002333</td>
<td>238158</td>
<td>075</td>
<td>003</td>
<td>172.16.14.23</td>
<td>1-1-05</td>
</tr>
<tr>
<td>TEST</td>
<td>00150002341</td>
<td>238159</td>
<td>075</td>
<td>004</td>
<td>172.16.14.24</td>
<td>1-1-05</td>
</tr>
<tr>
<td>TEST</td>
<td>00150002339</td>
<td>238186</td>
<td>075</td>
<td>006</td>
<td>172.16.14.26</td>
<td>1-1-06</td>
</tr>
</table>
</body>
</html>
如果面中多个表|而只需要对其中的一个表格的数据q行qo的话Q简单地把其中:$$('tr').each(function(ele, index) Ҏ $$('#tableId, tr').each(function(ele, index) p了,其中的tableId是表格的id ]]> Tapestry5.2的alpha版本已经发布 http://www.aygfsteel.com/usherlight/archive/2010/07/15/326156.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 15 Jul 2010 00:20:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/07/15/326156.html http://www.aygfsteel.com/usherlight/comments/326156.html http://www.aygfsteel.com/usherlight/archive/2010/07/15/326156.html#Feedback 2 http://www.aygfsteel.com/usherlight/comments/commentRss/326156.html http://www.aygfsteel.com/usherlight/services/trackbacks/326156.html
?.2中还是新增了不少令hȀ动的功能
1、QueryParameterMapped注解Q用这个注解可以很方便地把request中的参数映射到bean里的属?br />
2、(q是最让我期待的功能)服务l于能够动态加载了Q?br />
3、在事g处理Ҏ中可以用QueryParameter来注解参?br />
4、submitlg现在可以cancel表单里的数据?br />
5、不再用StAX作ؓtml的解析器了,而是采用标准的SAX解析器,q样减少外界引用Q而且兼容性更?br />
6、组件中也可以用SessionAttribute来获得session中的数据了,以前好像只有在page中才能用
7、引入了JSR-303 Bean Validation Integration Library. ]]> tapestry5.2 beta版已l完?/title> http://www.aygfsteel.com/usherlight/archive/2010/06/03/322593.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 03 Jun 2010 02:31:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/06/03/322593.html http://www.aygfsteel.com/usherlight/comments/322593.html http://www.aygfsteel.com/usherlight/archive/2010/06/03/322593.html#Feedback 1 http://www.aygfsteel.com/usherlight/comments/commentRss/322593.html http://www.aygfsteel.com/usherlight/services/trackbacks/322593.html
作者相信ga版本会在不久的未来发布?br />
所作者透露Q在新版本中会增加一个新的组Ӟdynamic.
q个lg的用途是更换皮肤。在旧版本的tapestry中,׃tapestry的模板是一致的Q所以要实现换肤相当困难?br />
但在新版本中的这个组件比较完地解决了这个问题?br />
作者自我评仯个组件是令hȀ动的一个新事物?br />
]]> 完美是优U的敌人The Perfect Is The Enemy Of The Good http://www.aygfsteel.com/usherlight/archive/2010/03/19/315858.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 18 Mar 2010 23:40:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/03/19/315858.html http://www.aygfsteel.com/usherlight/comments/315858.html http://www.aygfsteel.com/usherlight/archive/2010/03/19/315858.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/315858.html http://www.aygfsteel.com/usherlight/services/trackbacks/315858.html 伏尔泰的名句。在许多优秀的程序员的编E习惯中Q寻找解x案就如同是寻扑֥友一般,L力求完美Q如果一个解x案不够完的话,那么宁可舍弃也不会降低标准而采用。但是这Ll果很有可能会是一叉目,不见林?br />
举个实际的例子来_tapestry5的服务动态加载就是一个典型?br />
大家知道Q在Tapestry中,面模板的动态加载一直是其的一个宣传点。也是_面模板如果修改了,不需要重新启动应用服务器Q修改即时生效。但是,Tapestry却一直没有实现服务的动态加载,也就是说服务的类修改了,必重新启动服务器。ؓ什么呢Q因求完?br />
其实很久以前在Tapestry的作者的头脑中,包括许多的用户都惛_Tapestry中加入服务动态加载的功能Q但是最后作者却攑ּ了。原因是因ؓQ在Tapestry的架构中Q服务比面要复杂的多,服务不是单独存在的,他会被Inject到许多其他的服务Q而这些服务又会被inject到其他的服务中,最后导致你很难界定哪些c需要被重新加蝲?br />
但是最q有一个h提出一个徏议,Z么要实现完整的动态加载呢。其实只实现服务的实现类的动态加载就已经很好了?br />
实Q如果保持接口不变,只在接口具体实现修改的时候加载,实大大化了问题Q因样变化范围就被限定在单个cM内了。虽然这样ƈ不完,因ؓ如果改变了对外接口,比如Q添加了一个新的方法,或者改变了Ҏ的签名,q是需要重新启动服务器。可是这样也已经在很大程度上提升了用L使用满意度?br />
正如有句古语所_退一步v阔天I。也在此提醒自己在以后的开发过E中Q尽量拓展自q思维Q不要一下子d牛角里?br />
]]>Tapestry 最新版5.1.0.5教程Q十二)Q自定义前缀prefix http://www.aygfsteel.com/usherlight/archive/2010/03/06/314700.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 06 Mar 2010 07:54:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/03/06/314700.html http://www.aygfsteel.com/usherlight/comments/314700.html http://www.aygfsteel.com/usherlight/archive/2010/03/06/314700.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/314700.html http://www.aygfsteel.com/usherlight/services/trackbacks/314700.html 在教E的W四部分Qhttp://www.aygfsteel.com/usherlight/archive/2009/06/20/283396.htmlQ我们已l粗略地介绍了Tapestry的前~Q其中提及最常用的两Uliteral和prop。这里顺便再介绍一下其他的几个前缀.
1、contextQ这个经常在引用囄的时候用到。比如:<img src="${context:images/icon.png}"/> q样p够在面上显C在web-inf/images/icon.png
2、messageQ这个是需要I18N的应用必用的前缀?{message:some-key}
3、varQ用于定义生成一个时变量。比如:<li t:type="loop" source="1..10" value="var:index">${var:index}</li>。如果没有加q个前缀var:的话Q就需要在面cMd一个propertyQ?index以及相应的getter和setter?br />
我们q次介绍自定义一个cycle前缀Q这个可以用于在表格中显CZ同背景的行(也就是斑马条Q?br />
比如Q?br />
<t:grid .... rowClass="cycle:line1,line2">
...
</t:grid>
或?br />
<t:loop ...>
<div class="${cycle:line1,line2}">aaaa</div>
</tloop>
自定义prefix一般来说是3个步骤,
1、定义一个BindingFactoryQ这个需要实现BindingFactory接口
2、定义一个Bindingl承AbstractBinding
3、注册这个Binding
看一下具体的prefix的类Q?/p>
1 import java.util.ArrayList;
2 import java.util.List;
3
4 import org.apache.tapestry5.Binding;
5 import org.apache.tapestry5.BindingConstants;
6 import org.apache.tapestry5.ComponentResources;
7 import org.apache.tapestry5.ioc.Location;
8 import org.apache.tapestry5.services.BindingFactory;
9 import org.apache.tapestry5.services.BindingSource;
10
11 /** */ /**
12 * Implementation of the cycle: binding prefix -- we parse list of bindings
13 * and generate delegate bindings for each element<br>
14 * default binding is literal, other bindings can be used by specifying prefix.<br>
15 * example: "cycle:prop:name,prop:lastName,sth,sth else"
16 */
17 public class CycleBindingFactory implements BindingFactory {
18 private final BindingSource _bindingSource;
19
20 public CycleBindingFactory(BindingSource source) {
21 this ._bindingSource = source;
22 }
23
24 public Binding newBinding(String description, ComponentResources container, ComponentResources component,
25 String expression, Location location)
26 {
27 List< Binding > delegates = new ArrayList < Binding > ();
28 String[] bindingNames = expression.split( " , " );
29
30 for (String bindingName : bindingNames) {
31 String defaultBinding = BindingConstants.LITERAL;
32
33 Binding binding = _bindingSource.newBinding(description, container, component, defaultBinding, bindingName, location);
34 delegates.add(binding);
35 }
36
37 CycleBinding cycleBinding = new CycleBinding(delegates);
38 container.addPageLifecycleListener(cycleBinding);
39
40 return cycleBinding;
41 }
42 }
1 import java.util.List;
2
3 import org.apache.tapestry5.Binding;
4 import org.apache.tapestry5.internal.bindings.AbstractBinding;
5 import org.apache.tapestry5.runtime.PageLifecycleListener;
6
7
8 public class CycleBinding extends AbstractBinding implements PageLifecycleListener {
9 private final List < Binding > delegates;
10 private int index = 0 ;
11
12 public CycleBinding(List < Binding > delegates) {
13 this .delegates = delegates;
14 }
15
16 public Object get() {
17 Object ret = delegates.get(index).get();
18 index ++ ;
19 if (index >= delegates.size()) index = 0 ;
20 return ret;
21 }
22
23 @Override
24 public boolean isInvariant() {
25 return false ;
26 }
27
28 @Override
29 public Class < Object > getBindingType() {
30 return Object. class ;
31 }
32
33
34 public void containingPageDidDetach() {
35 index= 0 ;
36 }
37
38 public void containingPageDidAttach() { /**/ /* not interested */ }
39
40 public void containingPageDidLoad() { /**/ /* not interested */ }
41 }
Binding和BindingFactory写好了,注册后就可以使用了,注册的过E是在AppModel中添加以下一D代码:
1 public static void contributeBindingSource(
2 MappedConfiguration< String, BindingFactory > configuration,
3 BindingSource bindingSource
4 )
5 {
6 configuration.add(" cycle " , new CycleBindingFactory(bindingSource));
7 }
]]> Tapestry 最新版5.1.0.5教程Q十一Q:自定义组件CheckBoxGroup http://www.aygfsteel.com/usherlight/archive/2010/02/12/312607.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 11 Feb 2010 23:26:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/02/12/312607.html http://www.aygfsteel.com/usherlight/comments/312607.html http://www.aygfsteel.com/usherlight/archive/2010/02/12/312607.html#Feedback 3 http://www.aygfsteel.com/usherlight/comments/commentRss/312607.html http://www.aygfsteel.com/usherlight/services/trackbacks/312607.html
本文q一个实例来看一下Tapestry中是如何d一个自定义lg的?br />
Tapestry的内|组件只提供了checkboxQ而且只能q回一个booleanQ用于表明是否被选中?br />
比如Q要q行一个群众喜q水果调查Q选项? ҎQ葡萄,桃子Q香?..Q就需要对应每个选项讄一个布型变量Q显得比较繁琐?br />
q里我们添加一个组件用于将一lcheckbox集中hq回一个逗号分隔的字W串倹{?br />
通过查看Tapestry中的checkbox的源码(已经附在文章的后面)可以知道QTapestry可以很容易地通过Request来获取Form中的变量的倹{?br />
遇到的问题:
Tapestry的checkboxlg不允许设|相同的nameQ如果name相同QTapestry会自动在name后面d后缀来之不同?br />
If a component renders multiple times, a suffix will be appended to the to id to ensure uniquenessQhttp://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/Checkbox.htmlQ。如果各checkbox的name不同Q我们无法通过request来获得一lcheckbox的倹{?br />
思\Q?br />
在页面模板中不用tapestry的checkboxlgQ而用Html的checkboxQ这样可以避免tapestry自动修改checkbox的name?br />
d一个新的tapestrylgQ来映射接受所有同名的checkbox的|q把D回给tapestry面中对应的变量。这个组仉要有一个属性,q个属性的值就是所有同lcheckbox的nameQ这Pq个lg可以通过Request来获取所有相同name的checkbox的倹{?br />
代码Q?br />
1 public class CheckBoxGroup extends AbstractField {
2
3 @SuppressWarnings( " unused " )
4 @Parameter(required = true , autoconnect = true )
5 private String value;
6
7 @Parameter(required = true , autoconnect = true )
8 private String groupName;
9
10 @Inject
11 private Request request;
12
13 @SuppressWarnings( " unused " )
14 @Mixin
15 private RenderDisabled renderDisabled;
16
17 @Inject
18 private ComponentResources resources;
19
20 @BeginRender
21 void begin(MarkupWriter writer)
22 {
23 writer.element( " input " , " type " , " checkbox " ,
24 " name " , groupName,
25 " id " , getClientId(),
26 " style " , " display:none " );
27
28 resources.renderInformalParameters(writer);
29
30 decorateInsideField();
31 }
32
33 @AfterRender
34 void after(MarkupWriter writer)
35 {
36 writer.end(); // input
37 }
38
39 @Override
40 protected void processSubmission(String elementName)
41 {
42 String elementValue = "" ;
43 String[] valueArray = request.getParameters(groupName);
44 if ( valueArray != null && valueArray.length > 0 ) {
45 elementValue = valueArray[ 0 ];
46 for ( int i = 1 ; i < valueArray.length; i ++ ) {
47 elementValue += " , " + valueArray[i];
48 }
49 }
50 value = elementValue;
51 }
52 }
lg的用:
-----tml------
<t:CheckBoxGroup t:groupName="literal:bookId" t:value="selectedBooks"/>
<t:loop source="bookList" value="book" encoder="encoder">
<div><input type="checkbox" name="bookId" value="${book.id}"/> ${book.name}</div>
</t:loop>
注意checkBoxGroup的groupName和其他checkbox的name必须一_checkBoxGroup的value的值就是页面中的变量名
-----java-----
@SuppressWarnings("unused")
@Property
private final ValueEncoder<Book> encoder = new ValueEncoder<Book>() {
public String toClient(Book value) {
return String.valueOf(value.getId());
}
public Book toValue(String clientValue) {
return bookDao.getBook(Integer.parseInt(clientValue));
}
};
public List<Book> getBookList() {
return bookDao.getBooks();
}
@SuppressWarnings("unused")
@Property
private Book book;
@SuppressWarnings("unused")
@Property
private String selectedBooks;
]]> Tapestry 最新版5.1.0.5教程Q十Q:面间传递多个参?/title> http://www.aygfsteel.com/usherlight/archive/2010/02/06/312181.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 06 Feb 2010 04:36:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/02/06/312181.html http://www.aygfsteel.com/usherlight/comments/312181.html http://www.aygfsteel.com/usherlight/archive/2010/02/06/312181.html#Feedback 4 http://www.aygfsteel.com/usherlight/comments/commentRss/312181.html http://www.aygfsteel.com/usherlight/services/trackbacks/312181.html 在tapestry5中,在页面之间传递基本有3U方?br />
1、存攑֜Session?br />
2、用@Persistq行持久?br />
3、用页面context来传递参数?br />
其中1?都需要将数据存放在Session中,相对来说pȝ的开销比较大。尤其是多用户高q发情况下,对于性能可能会有一定的影响?br />
使用面Context来传递则需要在开发时写一些代码,增加了一些开发量Q显得没有前两种Ҏ方便?br />
W?U方法的实现是需要在面中添加onActivate和onPassivateҎ来完成页面参数的传递?br />
我们先来看一下其背后的故事?br />
举个例子Q比如说我们有两个页面,W一个是查询条g输入面inputQ另一个是查询l果输出面output。input面中有两个查询条gQv始时间dateFrom和终止时间dateTo
在Input.java中,我们可以很直观地q样写:
@InjectPage
private Output output;
@Property
private String dateFrom;
@Property
private String dateTo;
Object onFormSubmit() {
output.setDateFrom(dateFrom);
output.setDateTo(dateTo);
return output;
}
首先使用注解注入output面Q然后在表单的提交事件中Q返回outputQ这样就在程序中定义了返回页面,而不是用配|文件的方式?br />
但是q样的实现却不能正确q行Q原因是因ؓTapestry5的用了面池技术,面在每ơ渲染前都是从页面池中随取一个页面,而从面池中取得的页面,所有的属性都是被清空了的?br />
也就是说在上例中Q虽然我们注入了output面Q但是此面马上p攑օ了页面池Q而且其中的属性值马上就被清IZ。这是引入onActivate和onPassivateq丙个方法的原因。tapestry5在清I属性前会首先查看是否包含onPassivateҎQ如果有Q就把其q回g存v来,然后从页面池中取得页面后Q再把刚才保存的g为参C递给onActivateҎ?br />
q就是方?的基本原理,但是无论是在官方的文档或是示例或者网上其他的应用中,可以发现大部分都是用单个参数的Q比如说id。这也很Ҏ理解Q因为onPassivate的方法的q回值只能有一个?br />
在Tapestry5的官Ҏ档中Q只有一句非常简要的话介l了如果传递多个文档的ҎQ?The activation context may consist of a series of values, in which case the return value of the method should be an array or a List. Q参见:http://tapestry.apache.org/tapestry5.1/guide/pagenav.htmlQ?br />
但是qƈ不是说只要在onPassivate中把参数的值加入到List中,q回一个ListQ而在onActivate中接受一个List参数Q然后就可以得到其中的参CQ因为Tapestry5把参ClonActivate的方法其实是通过参C为HttpRequest中的参数的。如果试图用上q方法就是得C?#8220;无法List转换成String的错?#8221;
所以方法应该是q样的,在Output中:
private List<String> paramList;
public void setParamList(List<String> paramList) {
this.paramList = paramList;
}
public List<String> getParamList() {
return paramList;
}
List<String> onPassivate() {
return paramList;
}
void onActivate(String dateFrom, String dateTo) {
this.dateFrom = dateFrom;
this.dateTo = dateTo;
}
private String dateFrom;
private String dateTo;
在Input面中,需要把onFormSubmit改一下:
Object onFormSubmit() {
List<String> list = new ArrayList<String>();
output.setParamList(list);
return output;
}
其中Q需要注意的是output中的onActivateҎQ基参数的顺序必dList中放入的参数序一致?/p>
]]> Tapestry最新版5.1.0.5教程Q九Q:权限控制框架的实?q阶?/title> http://www.aygfsteel.com/usherlight/archive/2010/02/04/312016.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 04 Feb 2010 11:17:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/02/04/312016.html http://www.aygfsteel.com/usherlight/comments/312016.html http://www.aygfsteel.com/usherlight/archive/2010/02/04/312016.html#Feedback 1 http://www.aygfsteel.com/usherlight/comments/commentRss/312016.html http://www.aygfsteel.com/usherlight/services/trackbacks/312016.html 在上一中我们研究了如何实现SpringSecurity中Jsp Tag?lt;security:authorize ifAllGranted="ROLE_SUPERVISOR">的功能。这一ơ我们一LI一下如何实现在Tapestry5.1中添加一个Filter来对所有的操作q行权限的过滤控制?br />
在SpringSecurity中,我们一般是在application-context.xml中,d一个SpringSecurity的FilterQ然后在另外一个xml中详l配|如何根据Url的规则进行权限的控制。而Tapestry的哲学是量减少Xml中的配置Q其IOC容器也基本上是借鉴Guice而不Spring的)Q所以我们也是在代码中实现权限规则的控制?br />
M上来看,可以用两U方式来实现url规则Q一U是RequestU别的FilterQ一U是面lgU别的FilterQ如果是RequestU别的话Q可以从Request对象中获取Url路径Q这样就与SpringSecurity基本一样了。本文主要介l页面组件别的FilterQ从中我们也可以体会到Tapestry5.1中的IOC容器的强大和便利?/p>
q就是Filter的代码,q个Filter必须实现ComponentRequestFilter接口。值得注意的是其构造函数所需要用到的4个参敎ͼq?个参数都是Tapestry5本n自有的服务,所以我们什么也不用做,Tapestry5自动会将服务的实例注入进来,q就是Tapestry-IOC的威力?br />
ComponentRequestFilter接口一共有4个方法需要实玎ͼ具体代码如下Q?/p>
1 public class RequiresLoginFilter implements ComponentRequestFilter {
2
3 private final PageRenderLinkSource renderLinkSource;
4
5 private final ComponentSource componentSource;
6
7 private final Response response;
8
9 private final ApplicationStateManager appStateManager;
10
11 public RequiresLoginFilter(PageRenderLinkSource renderLinkSource,
12 ComponentSource componentSource, Response response,
13 ApplicationStateManager appStateManager
14 ) {
15 this .renderLinkSource = renderLinkSource;
16 this .componentSource = componentSource;
17 this .response = response;
18 this .appStateManager = appStateManager;
19 }
20
21 public void handleComponentEvent(
22 ComponentEventRequestParameters parameters,
23 ComponentRequestHandler handler) throws IOException {
24
25 if (dispatchedToLoginPage(parameters.getActivePageName())) {
26 return ;
27 }
28
29 handler.handleComponentEvent(parameters);
30
31 }
32
33 public void handlePageRender(PageRenderRequestParameters parameters,
34 ComponentRequestHandler handler) throws IOException {
35 if (dispatchedToLoginPage(parameters.getLogicalPageName())) {
36 return ;
37 }
38 handler.handlePageRender(parameters);
39
40 }
41
42 private boolean dispatchedToLoginPage(String pageName) {
43 Component page = componentSource.getPage(pageName);
44
45 if (page.getClass().isAnnotationPresent(RequiresLogin. class )) {
46 if ( ! appStateManager.exists(Authentication. class )) {
47 redirect();
48 return true ;
49 }
50 Authentication auth = appStateManager.get(Authentication. class );
51 if ( auth == null ) {
52 redirect();
53 return true ;
54 }
55
56 if ( ! auth.isLoggedIn()) {
57 redirect();
58 return true ;
59 }
60
61 RequiresLogin requireLogin = page.getClass().getAnnotation(
62 RequiresLogin. class );
63 String ifNotGranted = requireLogin.ifNotGranted();
64 String ifAllGranted = requireLogin.ifAllGranted();
65 String ifAnyGranted = requireLogin.ifAnyGranted();
66 boolean permitted = auth.checkPermission(ifNotGranted, ifAllGranted, ifAnyGranted);
67 if ( ! permitted ) {
68 return true ;
69 }
70 }
71
72 return false ;
73 }
74
75 private void redirect() {
76 Link link = renderLinkSource.createPageRenderLink( " Logout " );
77
78 try {
79 response.sendRedirect(link);
80 } catch (Exception e) {
81 }
82 }
83
84 }
在ComponentRequestFilter中,我们无法使用@SessionState注解来直接注入Session中的变量Q但是我们可以通过ApplicationStateManager来取得?/p>
现在我们需要把刚定义的Filter注册到系l中Q很单,只要在AppModule中添加以下函数就行了Q?/p>
1 public static void contributeComponentRequestHandler(
2 OrderedConfiguration < ComponentRequestFilter > configuration) {
3 configuration.addInstance( " RequiresLogin " , RequiresLoginFilter. class );
4 }
5
从本例子中我们可以看到Tapesty Ioc容器使用的便利性,也认识到了Ioc容器在Tapestry体系中的重要?img src ="http://www.aygfsteel.com/usherlight/aggbug/312016.html" width = "1" height = "1" /> ]]> Tapestry5.1中java.lang.ClassFormatError: Invalid length nnn in LocalVariableTable in class file 错误的解?/title> http://www.aygfsteel.com/usherlight/archive/2010/01/21/310302.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 20 Jan 2010 23:28:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/01/21/310302.html http://www.aygfsteel.com/usherlight/comments/310302.html http://www.aygfsteel.com/usherlight/archive/2010/01/21/310302.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/310302.html http://www.aygfsteel.com/usherlight/services/trackbacks/310302.html
Exception in thread "main" java.lang.ClassFormatError: Invalid length 561 in LocalVariableTable in class file
在网上搜索后Q发现有Z有同L错误Q解x法有两种Q?br />
http://mail-archives.apache.org/mod_mbox/tapestry-users/200909.mbox/%3Cecd0e3310909040909id5275beld935fc60d54d490a@mail.gmail.com%3E
其中一个h的错误原因是在其c\径中有不同版本的javassists的jar文g?br />
另一个的解决Ҏ是用eclipse自带的jdk来编译javacR?br />
而我自己仔细查了c\径中的文Ӟq没有重复的javassistsQ不q我觉得问题应该在javassists上,
因ؓq显然是javassists在操作class文g时报的错误,
我去|上搜烦q方面的信息Q发现有好几个h都和我一样在使用javassists3.11.0GA版本的时候,会出现这个错误?br />
后来Q我改用Tapestry5中自带的javassists3.9.0GA后,问题消失了?br />
q次l验教训是ƈ不是所有最新的东西都是最好的。合适的才是最好的?br /> ]]> Tapestry最新版5.1.0.5教程Q八Q:权限控制框架的实?基础?/title> http://www.aygfsteel.com/usherlight/archive/2010/01/12/309226.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 12 Jan 2010 12:17:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/01/12/309226.html http://www.aygfsteel.com/usherlight/comments/309226.html http://www.aygfsteel.com/usherlight/archive/2010/01/12/309226.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/309226.html http://www.aygfsteel.com/usherlight/services/trackbacks/309226.html
本文主要介绍如何实现cM于SpringSecurity的jsp tag的功能。在Tapestry中,利用Components实现q一炚w常容易?br />
其基本原理是Tapestry5中一个页面或者组件的渲染生成q程是基于一个状态机和队列完成的。这P渲染生成q程pl分成了很多个小模块Q我们可以非常容易地覆写q些模块。具体内容详见官Ҏ档:http://tapestry.apache.org/tapestry5.1/guide/rendering.html。如果权限校验不通过Q我们就可以控制不显C组件的内容?br />
我们q里是主要依赖q个q程来实现在面q一层面Ҏ限进行校验和控制?br />
代码主要包含两大部分Q一个组件和一个用于权限控制的服务?br />
参考了Tapestry-Spring-Security的实玎ͼ我也组件命名ؓIfRoleQ当Ӟ我们也可以和Tapestry-Spring-Security一P也再生成一个IfLoggedInlgQ。权限控制的服务我命名ؓQAuthenticationService?br />
主要的实现思\Q?br />
AuthenticationServicex为SessionState变量。这栯个变量就可以在所有的面和组件之间很方便地共享了。一般情况下Q是在登录页面对AuthenticationServiceq行赋|而在退出页面清IAuthenticationServiceq个变量?br />
代码Q这部分代码完全Ҏ应用的需求进自行更改Q:
AuthenticationService的代码:
public class AuthenticationService {
private List < String > privilegeList;
// privilegeList 的getter and setter
public boolean checkPermission(String ifNotGranted, String ifAllGranted,
String ifAnyGranted) {
if ((( null == ifAllGranted) || "" .equals(ifAllGranted))
&& (( null == ifAnyGranted) || "" .equals(ifAnyGranted))
&& (( null == ifNotGranted) || "" .equals(ifNotGranted))) {
return false ;
}
if (( null != ifNotGranted) && ! "" .equals(ifNotGranted)) {
StringTokenizer st = new StringTokenizer(ifNotGranted, " , " );
while (st.hasMoreTokens()) {
String value = st.nextToken();
if (privilegeList.contains(value)) {
return false ;
}
}
}
if (( null != ifAllGranted) && ! "" .equals(ifAllGranted)) {
StringTokenizer st = new StringTokenizer(ifAllGranted, " , " );
while (st.hasMoreTokens()) {
String value = st.nextToken();
if ( ! privilegeList.contains(value)) {
return false ;
}
}
}
if (( null != ifAnyGranted) && ! "" .equals(ifAnyGranted)) {
StringTokenizer st = new StringTokenizer(ifAnyGranted, " , " );
while (st.hasMoreTokens()) {
String value = st.nextToken();
if (privilegeList.contains(value)) {
return true ;
}
}
return false ;
}
return true ;
}
}
IfRole的代码(q个c需要放在Components目录下)Q?br />
public class IfRole {
/** */ /**
* A comma-separated list of roles is supplied to one or more of the
* following parameters. If none are supplied, the default behavior is to
* forbid access. Behavior should be self-explanatory.
*/
@Parameter(required = false , defaultPrefix = " literal " )
private String ifAllGranted;
@Parameter(required = false , defaultPrefix = " literal " )
private String ifAnyGranted;
@Parameter(required = false , defaultPrefix = " literal " )
private String ifNotGranted;
/** */ /**
* An alternate {@link Block} to render if the test parameter is false. The default, null, means
* render nothing in that situation.
*/
@Parameter(name = " else " )
private Block elseBlock;
private boolean test;
@SessionState
private AuthenticationService auth;
private boolean checkPermission() {
return auth.checkPermission(ifNotGranted, ifAllGranted, ifAnyGranted);
}
void setupRender() {
test = checkPermission();
}
/** */ /**
* Returns null if the test method returns true, which allows normal
* rendering (of the body). If the test parameter is false, returns the else
* parameter (this may also be null).
*/
Object beginRender() {
return test ? null : elseBlock;
}
/** */ /**
* If the test method returns true, then the body is rendered, otherwise not. The component does
* not have a template or do any other rendering besides its body.
*/
boolean beforeRenderBody() {
return test;
}
}
CZQ?br />
1. 在登录页面:
@SessionState
private Authentication auth;
......
// if user name and password is valid:
auth.setPrivliegeList(.....);
2. 在需要权限控制的面模板中:
<t:ifRole ifAllGranted="admin">
administrator can see this block
</t:ifRole>
]]> Tapestry最新版5.1.0.5教程Q七Q:与IBatis3的整?/title> http://www.aygfsteel.com/usherlight/archive/2010/01/06/308415.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 06 Jan 2010 04:20:00 GMT http://www.aygfsteel.com/usherlight/archive/2010/01/06/308415.html http://www.aygfsteel.com/usherlight/comments/308415.html http://www.aygfsteel.com/usherlight/archive/2010/01/06/308415.html#Feedback 2 http://www.aygfsteel.com/usherlight/comments/commentRss/308415.html http://www.aygfsteel.com/usherlight/services/trackbacks/308415.html
本文主要介绍如何Tapestry5.1和IBatis3q行整合?br zid="3" />
要步骤:
1. 准备工作
2. 数据库的建立
3. POJO的徏?br zid="7" />
4. IBatis相关配置文g的创?br zid="8" />
5. Tapestry相关代码的完?br zid="9" />
概要说明Q?br zid="10" />
1、准备工作。这一部分是比较简单的QEclipse之类的开发环境是必需的。Tapestry5.1、IBatis3Q目前还是Beta7Q、数据库Q我使用的是MySqlQ的下蝲安装?br zid="11" />
2、数据库的徏立,׃是示例,所以数据库的徏立也非常单,只有一张User表,3个字D,IdQNameQPassword
3、com.sample.Userc,对应数据库表?个字D,生成Userc?br zid="13" />
4、IBatis配置文gQConfiguration.xmlQUserMapper.xmlQjdbc.properties的生? 前两个必需Q最后一个可?
5、在AppModule里,使用buildҎ, d服务生成IBatis3的SqlSessionFactory, 在需要用SqlSessionFactory的地方,使用@InjectService注入卛_
详细说明Q?br zid="16" />
1、大家到各自的网站上下蝲相应的包好了。我只罗列一下我所用到的LibQ?br zid="23" />
antlr-runtime-3.1.1.jar
commons-codec-1.3.jar
commons-lang-2.4.jar
ibatis-3-core-3.0.0.216.jar
javassist.jar
log4j-1.2.14.jar
mysql-connector-java-5.0.5.jar
slf4j-api-1.5.10.jar
slf4j-log4j12-1.5.10.jar
stax2-api-3.0.1.jar
tapestry-core-5.1.0.5.jar
tapestry-ioc-5.1.0.5.jar
tapestry5-annotations-5.1.0.5.jar
woodstox-core-lgpl-4.0.7.jar
2、Create Table
DROP TABLE IF EXISTS `test`.`user`;
CREATE TABLE `test`.`user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`password` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
3?br zid="175" />
package com.sample.model;
public class User {
private long id;
private String name;
private String password;
// getter and setter ....
}
4、我把Configuration.xml和UserMapper.xml都放在src目录下,q样在部|的时候,是生成在classesQ也是c\径的根目录下?br zid="177" />
Configuration.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
<configuration>
<properties resource="jdbc.properties">
</properties>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="poolPingEnabled" value="${pingenable}"/>
<property name="poolPingQuery" value="${pingquery}"/>
<property name="poolPingConnectionsNotUsedFor" value="${pingnotusetime}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="UserMapper.xml"/>
</mappers>
</configuration>
UserMapper.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.sample.model.UserMapper">
<select id="selectUser" parameterType="int" resultType="com.sample.model.User">
select * from user where id = #{id}
</select>
</mapper>
jdbc.properties:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/test?autoReconnect=true
jdbc.username=root
jdbc.password=root
pingenable=true
pingquery=SELECT 1
pingoldertime=0
pingnotusetime=3600000
5?br zid="172" />
package com.sample.web.services;
public class AppModule {
public static SqlSessionFactory buildSqlSessionFactory() {
try {
String resource = "Configuration.xml";
Reader reader = Resources.getResourceAsReader(resource);
return new SqlSessionFactoryBuilder().build(reader);
} catch (Exception e) {
logger.warn("failed to build SqlSessionFactory: ", e);
return null;
}
}
private static Logger logger = LoggerFactory.getLogger(AppModule.class);
}
package com.sample.model;
public interface UserMapper {
public User selectUser(int id);
}
package com.pc.sample.web.pages;
public class Layout {
@InjectService("SqlSessionFactory")
private SqlSessionFactory sqlMapper;
public String getUserName() {
if ( sqlMapper == null ) {
return "null-mapper";
}
SqlSession session = sqlMapper.openSession();
try {
UserMapper userMapper = session.getMapper(UserMapper.class);
if ( userMapper == null ) {
return "null-userMapper";
}
User user = userMapper.selectUser(1);
if ( user == null ) {
return "null-user";
}
return user.getName();
} catch (Exception e) {
return "exception-" + e.getMessage();
} finally {
session.close();
}
}
}
几个注意事项Q?br zid="179" />
1Q?
因ؓ我的IBatis的配|文件Configuration.xml是放在类路径的根目录下,所以在初始化SqlSessionFactory的时候,?
接用String resource =
"Configuration.xml";p了,否则需要添加相应的路径Q比如:把Configuration.xml与UsercL在一P也就是在
com.sample.modelq个package中,那么p写成QString resource =
"com/sample/model/Configuration.xml";
同样Q在Configuration.xml中,指定UserMapper.xml的规则也是这L?br zid="181" />
2QUserMapper的用。Mapper的用是IBatis3中才有的新功能,也是IBatis用户指南中推荐用的方式。因样用的话,完全避免了cd的强制{换,实现了类型安全?br zid="182" />
需要注意的是UserMapper只是一个接口。我们不需要提供这个接口的具体实现。IBatis3会自动生成一个具体的实例?br zid="183" />
其中的方法名必须与UserMapper.xml中的select语句的id一栗在我的例子中是selectUser.
另外Q此Ҏ的返回值的cd必须与UserMapper.xml中配|的returnType一致?br zid="186" />
最后要提醒的是UserMapper.xml中的namespace必须是UserMapper的全cd,在本例中是com.sample.model.UserMapper ]]> Tapestry最新版5.1.0.5教程Q六Q:核心利器-IoC容器介绍 http://www.aygfsteel.com/usherlight/archive/2009/09/12/294895.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 12 Sep 2009 14:07:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/09/12/294895.html http://www.aygfsteel.com/usherlight/comments/294895.html http://www.aygfsteel.com/usherlight/archive/2009/09/12/294895.html#Feedback 1 http://www.aygfsteel.com/usherlight/comments/commentRss/294895.html http://www.aygfsteel.com/usherlight/services/trackbacks/294895.html 其核心思想是使用Java代码自n来解决依赖注入而不是由Xml之类的配|文件来完成Q这和Guice的思想是非常相似的QLewis也承认从Guice那里借鉴了不? 另外需要说明一下的是,Tapestyq从中国的一个非常古老但又充满哲理的游戏--围棋中借鉴了一些术语和思想。大意是围棋中经常要把棋子走的轻?Lightness)Q让每个子都能量地高效。编E也一栯轻量(Lightness)?nbsp; 阅读全文 ]]> Tapestry最新版5.1.0.5教程Q五Q:HelloCZE序的剖?/title> http://www.aygfsteel.com/usherlight/archive/2009/07/10/286315.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 10 Jul 2009 12:15:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/07/10/286315.html http://www.aygfsteel.com/usherlight/comments/286315.html http://www.aygfsteel.com/usherlight/archive/2009/07/10/286315.html#Feedback 5 http://www.aygfsteel.com/usherlight/comments/commentRss/286315.html http://www.aygfsteel.com/usherlight/services/trackbacks/286315.html
Ҏ前面?部分内容Q我们已l了解了Tapestry的基本概念,掌握了配|、组件等内容。现在我们通过剖析Tapestry的入门示例来对Tapestryq行一个M上认识?br />
1、web.xml
<web-app>
<display-name>app Tapestry 5 Application</display-name>
<context-param>
<!-- The only significant configuration for Tapestry 5, this informs Tapestry
of where to look for pages, components and mixins. -->
<param-name>tapestry.app-package</param-name>
<param-value>t5demo</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
q就是一个最单的Tapestry应用所需要配|的内容了?br />
a.context-param中的tapestry.app-package配置Q这在第一部分说过Q这是Tapestry要求配置的java package的名UͼTapestry相关内容都需要在q个package下面的pages, services, componets子package下。这里的配置是t5demo
b.TapestryFileter的配|。这个非常容易理解,几乎所有现在流行的web框架都需要一个类似的定义?/p>
2、start.tml以及相应的java classQ例子中是t5demo.pages.Start.java
Start.java非常单,只定义了一个getҎQ?br />
public class Start
{
public Date getCurrentTime()
{
return new Date();
}
}
相应的页面start.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<head>
<title>app Start Page</title>
</head>
<body>
<h1>app Start Page</h1>
<p> This is the start page for this application, a good place to start your modifications.
Just to prove this is live: </p>
<p> The current time is: ${currentTime}. </p>
<p>
[<t:pagelink t:page="Start">refresh</t:pagelink>]
</p>
</body>
</html>
首先要注意在html的tag中加入了Tapestry的命名空间?br />
W二?{currentTime}是Tapestry的Tag了,q里׃调用对应class的getCurrentTimeҎ在页面上昄对应的倹{?br />
W三?lt;t:pagelink>定义一个到自己本n面的链接,来完成刷新的d。t:pagelink在本pd的第4部分介绍q?/p>
3、需要的libraryQ?br />
commons-codec.jar
javassist.jar
log4j.jar
slf4j-api.jar
slf4j-log4j.jar
tapestry5-annotations-5.1.0.5.jar
tapestry-core-5.1.0.5.jar
tapestry-ioc-5.1.0.5.jar
4、再加上一个log4j.propertiesQ这是一个最单的tapestry应用所需要的全部东西了?br />
怎么P感觉q是挺简单的吧?/p>
]]> Tapestry最新版5.1.0.5教程Q四Q?/title> http://www.aygfsteel.com/usherlight/archive/2009/06/20/283396.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 20 Jun 2009 11:57:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/06/20/283396.html http://www.aygfsteel.com/usherlight/comments/283396.html http://www.aygfsteel.com/usherlight/archive/2009/06/20/283396.html#Feedback 3 http://www.aygfsteel.com/usherlight/comments/commentRss/283396.html http://www.aygfsteel.com/usherlight/services/trackbacks/283396.html 阅读全文 ]]> Tapestry最新版5.1.0.5教程Q三Q?/title> http://www.aygfsteel.com/usherlight/archive/2009/06/05/280207.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 05 Jun 2009 06:24:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/06/05/280207.html http://www.aygfsteel.com/usherlight/comments/280207.html http://www.aygfsteel.com/usherlight/archive/2009/06/05/280207.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/280207.html http://www.aygfsteel.com/usherlight/services/trackbacks/280207.html 阅读全文 ]]> Tapestry最新版5.1.0.5教程Q二Q箋 http://www.aygfsteel.com/usherlight/archive/2009/06/03/279852.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 03 Jun 2009 09:17:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/06/03/279852.html http://www.aygfsteel.com/usherlight/comments/279852.html http://www.aygfsteel.com/usherlight/archive/2009/06/03/279852.html#Feedback 2 http://www.aygfsteel.com/usherlight/comments/commentRss/279852.html http://www.aygfsteel.com/usherlight/services/trackbacks/279852.html 阅读全文 ]]> Tapestry最新版5.1.0.5教程Q二Q?/title> http://www.aygfsteel.com/usherlight/archive/2009/05/31/279277.html云自无心水自?/dc:creator>云自无心水自?/author>Sun, 31 May 2009 12:31:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/05/31/279277.html http://www.aygfsteel.com/usherlight/comments/279277.html http://www.aygfsteel.com/usherlight/archive/2009/05/31/279277.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/279277.html http://www.aygfsteel.com/usherlight/services/trackbacks/279277.html 阅读全文 ]]> Tapestry最新版5.1.0.5教程Q一Q?/title> http://www.aygfsteel.com/usherlight/archive/2009/05/30/279014.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 30 May 2009 05:55:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/05/30/279014.html http://www.aygfsteel.com/usherlight/comments/279014.html http://www.aygfsteel.com/usherlight/archive/2009/05/30/279014.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/279014.html http://www.aygfsteel.com/usherlight/services/trackbacks/279014.html 阅读全文 ]]> Tapestry5.1.0.5的性能试 http://www.aygfsteel.com/usherlight/archive/2009/05/16/271028.html云自无心水自?/dc:creator>云自无心水自?/author>Sat, 16 May 2009 11:38:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/05/16/271028.html http://www.aygfsteel.com/usherlight/comments/271028.html http://www.aygfsteel.com/usherlight/archive/2009/05/16/271028.html#Feedback 1 http://www.aygfsteel.com/usherlight/comments/commentRss/271028.html http://www.aygfsteel.com/usherlight/services/trackbacks/271028.html Ben Gidleyq行了一个关于Tapestry5.1.0.5的性能试。原文见Qhttp://blog.gidley.co.uk/2009/05/tapestry-load-testing-round-up.html
最后,他得出的l论是:
Q、Tapestry的速度是比较快的。即使在一定的压力下Tapestry的反应时间也相当短。Tapestryq不L最快的解决ҎQ但它对于我Q译注:GidleyQ已l够快了?br />
Q、Tapestry没有内存泄漏。我以前曄听说qTapestry会占用大量的内存Q实际上Q正好相反。它使用的内存比struts/jspq要。内存用曲U相当的q_?br />
Q、Tapestry在表单应用中比struts要快。Tapestry在应用变得非常复杂的时候有一定的优势。这可能利益于其模块池技术?br />
Q、Tapestry不轻易崩溃,即崩溃Q也会恢复。Tapestry在极大压力的情况下确实会相应变慢Q但是它会暂停或者遇到瓶颈(译注Q我怀疑是作者这里有W误Q从语气和上下文来看Q感觉应该不是暂停和没有瓉Q,q的是一个好事情。另外在压力减轻之后QTapestry能够自动恢复?br />
Q、更多的CPUq一定会提升性能。在一pd的测试中Q性能与CPU的数量ƈ不是U性增ѝ2个CPU实比一个CPU的性能d了Q但是4个CPUq不比2个CPU的性能d。因此,在多个双核CPU的虚拟机上运行,而不是少数的Q核CPU上运行?br />
Q、6Q位比3Q位要快。这一点很让我惊奇。不在Solarisq是Linux上,q行在6Q位JVM中要比在Q2位JVM要快?br />
Q、Linux要比Open Solaris X86要快。这一点同栯我惊奇。我本来以ؓ性能应该是相似的?br />
最l的l论是:Tapestry即是对于一个大q发量的Web应用来说也已l够快了。如果你的应用有性能问题的话Q那么问题应该出在你自己本n的代码上?/p>
上述是原文的译。下面是一些评论:
HowardQ应该是Tapestry的作者)QTaptestryQ和Struts相比Q我认ؓ差别应该是在反射的用上Q包括在java.bean.Introspector中大量的synchronizationQ。因此在Struts查询参数的名称映射成JavaBean属性的时候,会比较耗时。而TapestryQ是不用反的QTapestry在查询参数和JavaBean的属性之间用一U?#8220;预编E?#8221;向量lgQ也许这是两者(Tapestry和StrutsQ的差别。当Ӟq只是猜惻I如果要证实的话,是需要花费很多时间的。我认ؓOGNL的教训不是说反射很慢Q而是在于一个关键代码上的序列存取对于性能的媄响是相当大的?br />
最后一个小提示Q我觉得在Tapestry5应用中如果把BeanModel从BeanModelSource中只提取一ơ,然后lGridQBeanEditForm{等提供一个可以存取的ҎQ将会获得相当的性能提升。这样就不是需要每ơ都重徏BeanModelQ将减少操作的消耗?br />
jeverestQ我也进行了Tapestry的性能试Qƈ且同意TapestryQ的性能比较以前版本的要快?/p>
]]> Tapestry5.1正式发布 http://www.aygfsteel.com/usherlight/archive/2009/05/07/269484.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 07 May 2009 13:08:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/05/07/269484.html http://www.aygfsteel.com/usherlight/comments/269484.html http://www.aygfsteel.com/usherlight/archive/2009/05/07/269484.html#Feedback 0 http://www.aygfsteel.com/usherlight/comments/commentRss/269484.html http://www.aygfsteel.com/usherlight/services/trackbacks/269484.html Tapestry5.1l过Calpha,Beta版的非正式发布,今天l于在主늜到最l正式版5.1.0.5的发布?/p>
q次的版本算得上是比较迅速了Q从官方主页中可以看刎ͼW一?.1.0.1是2月2Q日发布了,短短Q个月不到的旉Q发了4个版本,动作不可谓不q速?br />
5.1中具有以下几个新Ҏ?br />
Q、Tapestry现在开始采用BlackBird作ؓJavaScript的调试工?br />
Q、一个Ajax的事件请求现在可以返回一个MultiZoneUpdate实例来更新浏览器中的多个?br />
Q、客L数字的检验实C国际?br />
Q、相对于5.0.18有显著的性能提升Q主要是面的加载时间和面的渲染时间大大羃?br />
Q、Tapestry的IoC服务现在既可以是Advised也可以是Decorated
Q、Tapestry的服务现在可以注入到Spring的Bean?br />
Q、对于支持Gzip的客LQTapestry现在可以压羃q回?br />
Q、有序的和Mapped的配|信息现在可以被重新赋?br />
Q、属性表辑ּ得到加强Q现在可以调用有参数的方法,或者创Z个列?br />
Q0、IoC的A献既可以是类Q自动生成实例)也可以是具体的实?br />
Q1、现在提供了一个简单的可以重写内徏服务的方?br />
q里面最让我感兴的q是性能的提升,不知道在展示大数据量的时候性能的提升到底有多少Q有Z一定要试一下?
]]> Tapestry和JSF比较 http://www.aygfsteel.com/usherlight/archive/2009/04/21/266866.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 21 Apr 2009 15:09:00 GMT http://www.aygfsteel.com/usherlight/archive/2009/04/21/266866.html http://www.aygfsteel.com/usherlight/comments/266866.html http://www.aygfsteel.com/usherlight/archive/2009/04/21/266866.html#Feedback 3 http://www.aygfsteel.com/usherlight/comments/commentRss/266866.html http://www.aygfsteel.com/usherlight/services/trackbacks/266866.html
最主要的原因还是从性能上的考虑?
Tapestry?.1版的最主要改动是x升性能Q而JSFgq没有这斚w的行动?br />
而且从Tapestry5.1的版本发布情冉|看,动作相当的迅速。预计Final版马上就要出来了?br />
据Lewis的说法,Tapestry5.0在页面内Ҏ较少的时候,速度几乎和纯JSP面一样快。只是在展示大量数据的会有一定的性能瓉?br />
所以,他推?.1来解册个问题?br />
而JSF的实现和lg库呈CU百花齐攄状态,隑օ会有一些良莠不齐?br />
当然大家需要选择其中比较好的Q但是选型本n是一仉常头疼的事情?br />
我选择的是MyFacesQRichFacesQ但是我查看了RichFaces的在UDemo后,对其展示速度不是很满意?br />
不知道是演示|站的问题还是RichFaces本n的问题?br />
也欢q大家进行讨论?br />
不过Tapestry相对JSF而言的一个缺点就是文档不够丰富。毕竟JSF是标准啊?img src ="http://www.aygfsteel.com/usherlight/aggbug/266866.html" width = "1" height = "1" /> ]]>
վ֩ģ壺
Ӫ |
|
Ǩ |
½ |
ͬ |
|
ij |
пѷ |
կ |
ƽԶ |
|
|
|
|
ǭ |
|
ɳ |
|
|
|
|
|
|
|
|
|
̩ |
º |
ͤ |
|
|
Ԫ |
|
˳ |
|
|
|
ף |
|
|
|