没有合适的资源?快使用搜索试试~ 我知道了~
首页JSF 2.0实战指南:100个高效控制应用的实用秘方
JSF 2.0实战指南:100个高效控制应用的实用秘方
需积分: 9 4 下载量 57 浏览量
更新于2024-07-30
收藏 2.35MB PDF 举报
"Packt JSF 2.0"是一本深入浅出的指南,专为JSF(JavaServer Faces)2.0开发者设计,提供了超过100个实用且效果显著的配方。这本书旨在帮助读者掌握和管理他们的JSF应用程序,使他们能够更有效地利用这一流行的Web开发框架。 JSF 2.0是Java平台企业版(Java EE)的一部分,它是一种基于组件的用户界面技术,简化了前端开发流程,允许开发者以声明式方式构建复杂的用户界面。书中涵盖了从基础概念到高级技巧的广泛内容,包括但不限于表单处理、数据绑定、事件处理、Ajax集成、JSF生命周期管理、以及如何优化性能和实现国际化等功能。 作者Anghel Leonard以其丰富的经验和深入理解,将复杂的技术问题分解成易于理解和执行的步骤,确保读者能够快速上手并解决实际开发中的挑战。每一章都包含具体的示例代码和详细的解释,使得读者能够通过实践学习和提升技能。 值得注意的是,本书版权由Packt Publishing所有,未经许可,不得复制、存储或通过任何形式或媒介进行传播。尽管作者和出版社已尽最大努力确保信息的准确性,但书中的内容并不保证完全无误,也不承担由此产生的任何直接或间接损失的责任。 《JSF 2.0 Cookbook》在2010年6月首次出版,经过多次修订和更新,以保持与最新技术同步。生产参考编号1310610表明这是一个特定版本的发行记录。这是一本适合初学者进阶和经验丰富的开发者参考的宝贵资源,无论是对于初次接触JSF的开发者,还是希望巩固现有知识的专业人士,都能从中获益良多。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/3844868/bg10.jpg)
Preface
5
If there is a book that you need and would like to see us publish, please send us a note in the
SUGGEST A TITLE form on www.packtpub.com or e-mail suggest@packtpub.com.
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book on, see our author guide on
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to
get the most from your purchase.
Downloading the example code for the book
Visit https://www.packtpub.com//sites/default/files/
downloads/9522_Code.zip to directly download the example code.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you nd a mistake in one of our books—maybe a mistake in the text or the code—we
would be grateful if you would report this to us. By doing so, you can save other readers from
frustration and help us improve subsequent versions of this book. If you nd any errata,
please report them by visiting http://www.packtpub.com/support, selecting your book,
clicking on the let us know link, and entering the details of your errata. Once your errata are
veried, your submission will be accepted and the errata will be uploaded on our website, or
added to any list of existing errata, under the Errata section of that title. Any existing errata
can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protection of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the location
address or website name immediately so that we can pursue a remedy.
Please contact us at
copyright@packtpub.com with a link to the suspected
pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with any
aspect of the book, and we will do our best to address it.
![](https://csdnimg.cn/release/download_crawler_static/3844868/bg11.jpg)
![](https://csdnimg.cn/release/download_crawler_static/3844868/bg12.jpg)
1
Using Standard and
Custom Converters
in JSF
In this chapter, we will cover:
Working with implicit and explicit conversions
Standard converters for numbers
Standard converters for date and time
Converters and NULL values
Creating and using a custom converter
Using converters for
h:selectOneMenu
Binding converters to backing bean properties
RichFaces and standard converters
RichFaces and custom converters
Instance variables in converters
Client-side converters with MyFaces Trinidad
![](https://csdnimg.cn/release/download_crawler_static/3844868/bg13.jpg)
Using Standard and Custom Converters in JSF
8
Introduction
Data conversion is the process of converting/transforming one data type into another. Before
going further and analyzing some aspects of JSF converters, let's see what they actually are
and what they are good for.
For this, let's take an example of a web application in which the user has to ll up a simple
form with some information, such as name, age, and date of birth. The server component
of our application will receive this information as strings, even if we know that they are a
string (the name), an integer (the age), and a date (the date of birth). This is the phase when
JSF converters enter into the scene and convert the user input according to application
requirements. If the submitted information is not successfully converted then the form is
redisplayed (this time an attention message is also displayed) and the user can rell the form.
The case repeats until the submitted information is successfully converted to the correct type.
In addition, you should know that JSF provides a set of standard converters (used for the
most common conversions) and the possibility to dene your own converters, known as
custom converters (this kind of converters are very useful when the standard converters can't
accomplish the desired conversions). Speaking of standard converters, the following are the
most used converters:
Converter IDs Converter class
javax.faces.Byte javax.faces.convert.ByteConverter
javax.faces.Float javax.faces.convert.FloatConverter
javax.faces.BigInteger javax.faces.convert.BigIntegerConverter
javax.faces.BigDecimal javax.faces.convert.BigDecimalConverter
javax.faces.Character javax.faces.convert.CharacterConverter
javax.faces.DateTime javax.faces.convert.DateTimeConverter
javax.faces.Boolean javax.faces.convert.BooleanConverter
javax.faces.Double javax.faces.convert.DoubleConverter
javax.faces.Long javax.faces.convert.LongConverter
javax.faces.Short javax.faces.convert.ShortConverter
javax.faces.Integer javax.faces.convert.IntegerConverter
Some JSF tags that support converters are as follows:
<h:outputText>
<h:outputLink>
<h:selectManyListbox>
<h:selectMaynyMenu>
<h:inputTextarea>
![](https://csdnimg.cn/release/download_crawler_static/3844868/bg14.jpg)
Chapter 1
9
<h:inputHidden>
<h:outputLabel>
<h:inputText>
<h:inputSecret>
<h:selectBooleanCheckbox>
<h:selectOneRadio>
<h:selectOneListbox>
<h:outputFormat>
<h:selectOneMenu>
Speaking about a converter lifecycle, you should focus on two main phases named: Apply
Request Values Phase and Render Response Phase. For example, if we assume a form
that is submitted with a set of values, a converter for those values, a corresponding backing
bean, and a render page, then the application lifecycle will be like this (notice when and where
the converter is involved!):
Restore View Phase: The backing bean is created and the components are stored
into the UIViewRoot.
Apply Request Values Phase: The submitted values are decoded and set in the
corresponding components in UIViewRoot.
Process Validations Phase: The converter getAsObject method receives the
submitted values (eventually a potential validator is also called).
Update Model Values Phase: The converted (validated) values are set in the
backing bean.
Invoke Application Phase: The phase responsible for form processing.
Render Response Phase: The values that should be displayed are extracted from
a backing bean. The getAsString method of the converter receives these values
before rendering. The conversion results are redirected to the result page.
Using the proper converter is the developer's choice. The developer is also responsible for
customizing the error messages displayed when the conversion fails. When the standard
converters don't satisfy the application needs, the developer can write a custom converter
as you will see in our recipes.
Notice that our recipes make use of JSF 2.0 features, such as annotation, new
navigation style, and no faces-config.xml le. Especially you must notice the new
@FacesConverter annotation for indicating to a normal class that it is a JSF 2.0 converter.
Let's start with a simple recipe about working with implicit and explicit conversions.
剩余395页未读,继续阅读
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
hbzhang11
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 解决本地连接丢失无法上网的问题
- BIOS报警声音解析:故障原因与解决方法
- 广义均值移动跟踪算法在视频目标跟踪中的应用研究
- C++Builder快捷键大全:高效编程的秘密武器
- 网页制作入门:常用代码详解
- TX2440A开发板网络远程监控系统移植教程:易搭建与通用解决方案
- WebLogic10虚拟内存配置详解与优化技巧
- C#网络编程深度解析:Socket基础与应用
- 掌握Struts1:Java MVC轻量级框架详解
- 20个必备CSS代码段提升Web开发效率
- CSS样式大全:字体、文本、列表样式详解
- Proteus元件库大全:从基础到高级组件
- 74HC08芯片:高速CMOS四输入与门详细资料
- C#获取当前路径的多种方法详解
- 修复MySQL乱码问题:设置字符集为GB2312
- C语言的诞生与演进:从汇编到系统编程的革命
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)