- 浏览: 60188 次
- 性别:
- 来自: 四川
最新评论
转自:http://tapestry.apache.org/enum-parameter-recipe.html
It's not uncommon to create a component that has a bit of complex behavior that you want to be able to easily control, and an enumerated type (a Java enum) seems like the right approach.
Our example comes from Tapestry's Select component, which has a blankOption parameter that an enum type.
Let's start with the enum type itself:
public enum BlankOption
{
/**
* Always include the blank option, even if the underlying property is required.
*/
ALWAYS,
/**
* Never include the blank option, even if the underlying property is optional.
*/
NEVER,
/**
* The default: include the blank option if the underlying property is optional.
*/
AUTO;
}
Next, we define the parameter:
The final piece of the puzzle is to inform Tapestry how to convert from a string, such as "never", to a BlankOption value.
public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
{
. . .
add(configuration, BlankOption.class);
. . .
}
private static <T extends Enum> void add(Configuration<CoercionTuple> configuration, Class<T> enumType)
{
configuration.add(CoercionTuple.create(String.class, enumType, StringToEnumCoercion.create(enumType)));
}
The TypeCoercer service is ultimately responsible for converting the string to a BlankOption, but we have to tell it how, by contributing an appropriate CoercionTuple. The CoercionTuple identifies the source and target types (String and BlankOption), and an object to perform the coercion (an instance of StringToEnumCoercion, via the create() static method).
发表评论
-
struts2 中获取 web资源的方式
2016-01-08 17:02 475在struts2中获取 web资源的方式大致可分为获取扩展 ... -
sql server、db2、oracle 存储过程动态sql语句示例
2015-01-31 19:00 1793Oracle CREATE OR REPLACE PRO ... -
ie9 中出现不明的异常(参数是必选项 (Argument not optional)、尚未实现)等
2015-01-27 23:57 1271<script type="text/jav ... -
SAXParseException: The content of element type "configuration" must match
2014-09-15 23:57 1926在mybatis的配置文件中新增加<databaseI ... -
java.lang.ClassNotFoundException: Cannot find class: DB_VENDOR
2014-09-15 23:45 1932在mybatis 中使用databaseIdProvide ... -
spring mvc3 + fastjson 转换 REST 参数以及输出
2014-03-27 00:16 4194spring 3可以支持Rest风格参数,其内置了jack ... -
eclipse中编辑log4j 的xml配置文件时,自动提示
2014-03-27 00:05 843方法1. 配置log4j.dtd文件: Windows - ... -
java json 转换之 Jackson 框架
2013-08-01 21:50 1114转自:http://www.cnblogs.com/hooj ... -
eclipse/myeclise 自定义注释中的变量名称
2013-07-01 23:18 939eclipse/myeclipse中自带了 ... -
Eclipse Class Decompiler——Java反编译插件
2012-11-08 22:41 1206Eclipse Class Decompiler,整 ... -
struts+spring+hibernate整合问题解决方法 陆续更新中....
2009-01-01 10:33 845在整合ssh过程中出现的问题和解决方法: 一、 严重: Ser ... -
DWR通过Annotation与spring整合
2009-01-21 22:05 636DWR 2.0 增加了一个很有趣的新特性,Annotat ... -
div嵌套页面 div加载页面 (其中获取目标页面的内容是用dwr框架连接java程序做的)
2009-03-15 16:58 630前段时间因为有需要,要在div中加载一个页面。但是以前没做过, ... -
tapestry autocomplete 更改样式及定位
2009-07-09 19:02 682版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文 ... -
Java中的main()方法详解
2009-07-12 16:23 610源文作者:leizhimin 源文链接:http:/ ... -
tapestry5 集成 spring 的事务管理
2009-07-22 15:43 558说明:使用的是tapestry5.1.0.5 和spring ... -
tapestry5 布局 参数的处理
2009-07-23 17:24 378<?xml version="1.0" ... -
tapestry不支持 等html特殊符号的解决方法
2009-07-23 17:34 481在使用tapestry时,偶然发现使用 &a ... -
WebService大讲堂之Axis2(1):用POJO实现0配置的WebService
2009-07-28 15:01 402转自:http://space.itpub.net ... -
WebService大讲堂之Axis2(2):复合类型数据的传递
2009-07-28 15:25 472转自:http://space.itpub.net/12921 ...
相关推荐
tapestry4.02中封装ext的GridPanel组件
tapestry4.02中封装ext的TabPanel组件
tapestry hibernate Spring应用及组件的使用的一个简单完整例子,包含form组件、table组件的一个增删改查。其中数据库创建用户和表在docs里,数据库使用oracle
自定义的邮件组件!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
tapestry部分组件绑定参数的列表!
介绍Tapestry组件的使用和功能。内容还行,使用初学者入门。
Tapestry 4 官方文档中文版本,现在中文资料比较少,和大家共享一下
tapestry页面编辑组件,可以实现文本框,单选框,多选框和下拉框等的自动生成,并返回改变后的数据。
tapestry5组件说明使用及登陆修改等简单实例
Tapestry 4 官方文档中文版本,包括Tapestry4 Quick Start(2)和Tapestry4 Users Guide(2)两个文档 还有tapestry中文字典等
来自:http://tapestry.apache.org/tapestry5.1/tapestry-core/ref
本文介绍Tapestry框架版本5。本文利用Tapestry 5开发一个简单的具有创建/读/更新/删除功能的应用,在创建这个应用的过程中,本文体会到Tapestry...还将了解如何应用Tapestry中内嵌的Ajax功能来创建支持Ajax的组件。
Apache Tapestry是一个使用Java语言创建web应用的面向组件的开发框架。Tapestry应用建立在根据组件构建的页面的基础上。这个框架能够提供输入验证(input validation)、本地化/国际化(localization/...
2)Tapestry 各种核心组件的使用 3)自带验证,自定义验证,验证码的生成 4)Tree组件的使用,Grid的各种使用(修改样式,排序,隔行换色等等),Loop组件的使用 5)集合Spring4.0.5实现的增删改查 等等 如果你是新...
Tapestry5最新中文教程.doc 作者 Renat Zubairov & Igor Drobiazko译者 沙晓兰 发布于 2008年7月2日 下午9时30分 社区 Java 主题 Web框架 ----------------------------------------- Tapestry5.1实例教程.pdf ...
引用Tapestry网站上的一句话:"Tapestry用对象(objects),方法(methods),属性(PRoperties)替代以往的URLs和查询参数, 重新诠释Web应用开发.Tapestry 3.0即将发布,它有大量的改进和新的特性.你值得拥有!!!!
tapestry5组件说明使用等简单实例。Apache Tapestry是一个使用Java语言创建web应用的面向组件的开发框架。Tapestry应用建立在根据组件构建的页面的基础上。这个框架能够提供输入验证(input validation)、本地化/...
Drobiazko和R. Zubairov合作撰写了一篇文章,详细介绍Apache Tapestry 版本5——一个...文章向读者展示了创建组件方法,并谈到了Tapestry中的IoC以及Ajax的相关特性 译者 沙晓兰 发布于 2008年7月2日 下午9时30分
使读者在学习如何使用Tapestry框架技术的同时,还能够获得在J2EE Web应用程序中应用Tapestry框架的先进经验。本书详细介绍了Hivemind框架的原理与应用,使读者不但可以通过Hivemind来重构Tapes 资源太大,传百度网盘...
Tapestry是一个开源的基于servlet的应用程序框架,它使用组件对象模型来创建动态的,交互的web应用。一个组件就是任意一个带有jwcid属性的html标记。其中jwc的意思是Java Web Component。Tapestry使得java代码与html...