第十二讲:tapestry actionlink与eventlink组件

actionlink与eventlink组件非常相似,都是执行一个事件,在代码编写上有一点点差异。源代码如下:

MyEvent.java

/**
* 项目名称:TapestryStart
* 开发模式:Maven+Tapestry5.x+Tapestry-hibernate+Mysql
* 版本:1.0
* 编写:飞风
* 时间:2012-02-29
*/
package com.tapestry.app.pages;
 
import org.apache.tapestry5.annotations.PageActivationContext;
import org.apache.tapestry5.annotations.Property;
 
public class MyEvent {
 
@Property
@PageActivationContext
private int count;
 
//执行eventlink递增加+1,newCount就是默认值1
void onAdd(int newCount){
count += newCount;
}
 
//执行actionlink递增加+2,meCount就是默认值2
void onActionFromAddTwo(int meCount){
count += meCount;
}
 
//设置为0
void onClear(){
count = 0;
}
}
 

MyEvent.tml

<html t:type="layout" title="tapestryStart Index"  t:sidebarTitle="Framework Version"
 xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<div style="color:#ff6600">${count}</div>
<t:eventlink t:event="add" t:context="literal:1">单击递增1,初始值为1</t:eventlink><br/>
<t:actionlink t:id="addTwo" t:context="literal:2">单击递增2,初始值为2</t:actionlink><br/>
<a href="#;" t:type="eventlink" t:event="clear">清除</a>
</html>

http://localhost/myevent

转载于:https://my.oschina.net/shootercn/blog/53441

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值