2019独角兽企业重金招聘Python工程师标准>>>

源码如下:

AJAXSelect1.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.ComponentResources;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
public class AJAXSelect1 {
static final private String[] ALL_MAKES = new String[] { "梅州市", "河源市" };
static final private String[] NO_MODELS = new String[] {};
static final private String[] MEIZHOU_MODELS = new String[] { "五华县", "兴宁县"};
static final private String[] HEYUAN_MODELS = new String[] { "紫金县", "龙川县" };
@Property
private String areaMake;
@Property
private String cithModel;
@Property
private String keywords;
@Property
private String[] areaMakes;
@Property
@SuppressWarnings("unused")
private String[] cithModels;
@InjectPage
private AJAXSelect2 page2;
@InjectComponent
private Zone cithModelZone;
@Inject
private ComponentResources componentResources;
@Inject
private Request request;
void setupRender() {
if (areaMakes == null) {
areaMakes = ALL_MAKES;
cithModels = NO_MODELS;
}
}
Object onValueChangedFromAreaMake(String areaMake) {
this.areaMake = areaMake;
areaMakes = ALL_MAKES;
if (areaMake == null) {
cithModels = NO_MODELS;
}
else if (areaMake.equals(areaMakes[0])) {
cithModels = MEIZHOU_MODELS;
}
else if (areaMake.equals(areaMakes[1])) {
cithModels = HEYUAN_MODELS;
}
else {
cithModels = NO_MODELS;
}
cithModel = null;
return request.isXHR() ? cithModelZone.getBody() : null;
}
Object onSuccess() {
page2.set(areaMake, cithModel, keywords);
componentResources.discardPersistentFieldChanges();
return page2;
}
Object onGoHome() {
componentResources.discardPersistentFieldChanges();
return Index.class;
}
}

AJAXSelect1.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">
<form t:type="form" t:id="searchCriteria">
<t:label for="areaMake"/>:
<select t:type="select" t:id="areaMake" t:model="areaMakes" t:zone="cithModelZone"
t:blankOption="ALWAYS" t:blankLabel="请选择" t:validate="required"/>
<t:zone t:id="cithModelZone" id="cithModelZone" style="display: inline;">
<t:label for="cithModel"/>:
<select t:type="select" t:id="cithModel" t:model="cithModels" 
t:blankOption="ALWAYS" t:blankLabel="请选择" t:validate="required"/>
</t:zone>
说明: <input t:type="TextField" t:id="keywords"/> (optional)<br/> 
<input type="submit" value="提交"/>
<t:errors/>
</form><br/>
</html>

AJAXSelect2.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.PersistenceConstants;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
public class AJAXSelect2 {
@Persist(PersistenceConstants.FLASH)
@Property
@SuppressWarnings("unused")
private String areaMake;
@Persist(PersistenceConstants.FLASH)
@Property
@SuppressWarnings("unused")
private String cithModel;
@Persist(PersistenceConstants.FLASH)
@Property
@SuppressWarnings("unused")
private String keyWords;
public void set(String areaMake, String cithModel, String keyWords) {
this.areaMake = areaMake;
this.cithModel = cithModel;
this.keyWords = keyWords;
}
}

AJAXSelect2.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">
您选择的地区是: ${areaMake} ${cithModel} ${keyWords}!<br/><br/>
</html>

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

第三十八讲:tapestry Ajax 关联下拉选框(select)组件相关推荐

  1. Ajax异步配合数据字典完成下拉选框

    Ajax异步配合数据字典完成下拉选框 在一个web项目中,往往有许多下拉选框,其中下拉选框必须含有特定的内容,而如果在jsp或者html页面中写死的话就很难修改,也不能动态获取到更新的数据,所以要使用 ...

  2. 第三十三讲:tapestry Ajax eventlink无刷新页面

    2019独角兽企业重金招聘Python工程师标准>>> tapestry的Ajax使用非常简单,Ajax的页面无刷新,刚好解决了eventlink.actionlink等组件无刷新, ...

  3. 第三十五讲:tapestry Ajax zone组件无黄色闪烁的背景

    2019独角兽企业重金招聘Python工程师标准>>> 实现方法很简单,在zone组件里加上t:update="show"就不会出现黄色背景了.源码如下: Zon ...

  4. 线性代数学习笔记——第三十八讲——直线与直线的位置关系

    1. 直线与直线的位置关系1--平行但不重合 2. 直线与直线的位置关系2--重合 3. 直线与直线的位置关系3--相交 4. 直线与直线的位置关系4--异面 5. 两直线的夹角的定义 6. 两直线位 ...

  5. 第三十八讲项目二 打豆豆

    1.任务和代码 /* copyright\c)2017,csdn学院 *All cights reserved *文件名称:a.c *作者:王琦 *完成日期:2017年4月23日 *版本号:6.0 * ...

  6. 如何选择适合你的兴趣爱好(三十八),爵士舞

    围城网的摇摇今天给大家带来了"如何选择适合你的兴趣爱好"系列专辑的第三十八讲--爵士舞.爵士舞是一种急促又富动感的节奏型舞蹈,是属于一种外放性的舞蹈.爵士舞动作是一种自由而纯朴的表 ...

  7. OpenCV学习笔记(三十六)——Kalman滤波做运动目标跟踪 OpenCV学习笔记(三十七)——实用函数、系统函数、宏core OpenCV学习笔记(三十八)——显示当前FPS OpenC

    OpenCV学习笔记(三十六)--Kalman滤波做运动目标跟踪 kalman滤波大家都很熟悉,其基本思想就是先不考虑输入信号和观测噪声的影响,得到状态变量和输出信号的估计值,再用输出信号的估计误差加 ...

  8. CCNA实验三十八 ZFW(区域防火墙)

    CCNA实验三十八 ZFW(区域防火墙) 环境:Windows XP .Packet Tracert5.3 目的:了解ZFW的原理与基本配置 说明: ZFW(Zone-Based Policy Fir ...

  9. 小甲鱼Python3学习笔记之第二十八讲(仅记录学习)

    第二十八讲:文件:因为懂你,所以永恒 一.知识点: 0.file对象利用open函数来创建. 1.file文件的打开模式:f = open('文件地址','r/w/x/a等') 'r':只读模式,以只 ...

最新文章

  1. 手把手教你入门和实践特征工程 的全方位万字笔记,附代码下载
  2. Java黑皮书课后题第5章:**5.22(金融应用:显示分期还贷时间表)对于给定的贷款额,月支付额包括偿还本金及利息。编写一个程序,让用户输入贷款总额年限利率,然后显示分期还贷时间表
  3. ubuntu linux theme,如何在Ubuntu 20.04中启用全局暗黑主题
  4. 用Python创建漂亮的交互式可视化效果
  5. 奇妙的安全旅行之国密算法
  6. 北大青鸟消防控制器组网_北大青鸟JBF-61S20防火门监控器控制器接线示意图
  7. 心得 | 《用得上的商学课》 004 边际成本 | 飞机起飞前的座位,只卖一块钱?...
  8. 前端把cookie写在父域里_单点登录的三种实现方式
  9. c编程技巧——获取可用的处理器(CPU)核数
  10. TextBox设置ReadOnly属性后后台得不到值解决方法 [转]
  11. Spring Aop中@Pointcut用法
  12. 量子统计巨正则系综应用理想费米气体与波色气体性质详解
  13. Postman下载安装
  14. 用计算机收传真,使用计算机发送和接收传真.doc
  15. oracle sqlldr原理,oracle sqlldr 参数说明
  16. tensorflow下手写汉字识别及其可视化
  17. 认识常见壳与程序的特征
  18. 职业能力测试之逻辑(一)
  19. 比excel好用,还能解决数据孤岛问题,这款报表工具千万别错过
  20. 科技云报道:安全脱管不如托管

热门文章

  1. git cherry-pick
  2. zookeeper动物园管理员学习笔记
  3. LeetCode-35. Search Insert Position
  4. 【整理总结】Visual Studio 扩展和更新
  5. 程序员之工具杂烩(一)
  6. Python:Python学习总结
  7. 代码坏味道 - 耦合
  8. 【HeadFirst设计模式】8.模板方法模式
  9. Linux性能测试 KSysguard工具
  10. ajaxToolkit发布之后出错!说未能加载文件或程序集!