第三十九讲:tapestry 页面加载等待过程(ProgressiveDisplay)组件

ProgressiveDisplay组件其实就是londing。在请求没完成时调出一个等待的gif动画,告诉用户请求没完成请等待!代码如下:

ProgressiveDisplay.java 

/**
 * 项目名称:TapestryStart
 * 开发模式:Maven+Tapestry5.x+Tapestry-hibernate+Mysql
 * 网址: http://www.flywind.org
 * 版本:1.0
 * 编写:飞风
 * 时间:2012-02-29
 */
package com.tapestry.app.pages;
 
import org.apache.tapestry5.annotations.Property;
 
public class ProgressiveDisplay {
static final private String[] ALL_THINGS = { "吃饭", "睡觉", "绘画" } ;
 
@Property
@SuppressWarnings("unused")
private String[] things;
 
@Property
@SuppressWarnings("unused")
private String thing;
 
public void onProgressiveDisplayFromShowThings() {
 
things = ALL_THINGS;
 
sleep(5000);
 
}
 
private void sleep(long millis) {
try {
Thread.sleep(millis);
}
catch (InterruptedException e) {
 
}
}
}
 

ProgressiveDisplay.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">
<t:ProgressiveDisplay t:id="showThings" style="margin-left: 10px;">
<div t:type="Loop" t:source="things" t:value="thing">
${thing}
</div>
</t:ProgressiveDisplay><br/> 
</html>

你可能感兴趣的:(第三十九讲:tapestry 页面加载等待过程(ProgressiveDisplay)组件)