第三十四讲:tapestry Ajax actiontlink无刷新页面

不想你离开。 提交于 2019-12-06 02:40:57

源码如下:

AJAXActionLink.java

/**
 * 项目名称:TapestryStart
 * 开发模式:Maven+Tapestry5.x+Tapestry-hibernate+Mysql
 * 版本:1.0
 * 编写:飞风
 * 时间:2012-02-29
 */
package com.tapestry.app.pages;
 
import java.util.Date;
 
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
 
public class AJAXActionLink {
 
@Inject
private Request reauest;
 
@InjectComponent
private Zone time2Zone;
 
void onActionFromRefreshPage(){}
 
Object onActionFromRefreshZone(){
return reauest.isXHR()? time2Zone.getBody():null;
}
 
public Date getServerTime1(){
return new Date();
}
 
public Date getServerTime2(){
return new Date();
}
}
 

AJAXActionLink.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="margin-left: 50px">
<a t:type="actionlink" t:id="refreshPage" href="#">ActionLink刷新页面</a><br/>
<a t:type="actionlink" t:id="refreshZone" href="#" t:zone="time2Zone">ActionLink AJAX无刷新</a><br/><br/>
 
serverTime1:  ${serverTime1}
<t:zone t:id="time2Zone">
serverTime2:  ${serverTime2}
</t:zone><br/>
</div>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!