jsf in action 笔记:页面语言(Expression Language)--2008.04.09

本文介绍了如何使用JSF表达式语言(EL)连接组件到JavaBean属性、集合及简单数据类型。此外还展示了如何引用方法、创建逻辑或数值表达式,并支持嵌套属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2008.02.09 摘自 JSF in action 2.4 Exploring the JSF expression language    Page/110

Table 2.3 You can use the JSF EL to wire components to objects that expose JavaBean properties,
collections, and simple data types. The EL can also be used to reference methods and create logical
or numeric statements. In addition, nested properties are supported.

 ExampleDescription 
 #{myBean.value} Returns the value property of the object stored under the key
myBean, or the element stored under the key value if myBean is a
Map.
 #{myBean['value']} Same as "{#myBean.value}".
 #{myArrayList[5]} Returns the fifth element of a List stored under the key
myArrayList.
 #{myMap['foo']} Returns the object stored under the key foo from the Map stored
under the key myMap.
 #{myMap[foo.bar]} Returns the object stored under the key that equals the value of the
expression foo.bar from the Map stored under the key myMap.
 #{myMap['foo'].value} Returns the value property of the object stored under the key foo
from the Map stored under the key myMap.
 #{myMap['foo'].value[5]} Returns the fifth element of the List or array stored under the key
foo from the Map stored under the key myMap.
 #{myString} Returns the String object stored under the key myString.
 #{myInteger} Returns the Integer object stored under the key myInteger.
 #{user.role == 'normal'} Returns true if the role property of the object stored under the key
user equals normal. Returns false otherwise.
 #{(user.balance - 200)
== 0}
 If the value of the balance property of the object stored under the
key user minus 200 equals zero, returns true. Returns false otherwise.
 Hello #{user.name}! Returns the string "Hello" followed by the name property of the object
stored under the key user. So if the user’s name is Sean, this would
return "Hello Sean!"
 You are #{(user.balance
> 100) ? 'loaded' : 'not
loaded'}
 Returns the string "You are loaded" if the balance property of the
object stored under the key user is greater than 100; returns "You
are not loaded" otherwise.
 #{myBean.methodName} Returns the method called method of the object stored under the
key myBean.
 #{20 + 3} Returns 23.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值