jsf in action 笔记:在组件中使用EL语言(Using the EL with components)--2008.04.11

来源:互联网 发布:硬盘在mac机不能复制 编辑:程序博客网 时间:2024/05/19 13:09

2008.04.11 摘自 JSF in action 2.4.3 Using the EL with components Page/117

JSF的EL表达式可以将组件与Backing Bean或者Model Object联系起来,可以将组件中的展现与对象中的属性的值动态关联,也可以将某个按钮与Backing Bean对象中的某个方法关联起来,包可以将整个组件与对象中的某个属性关联.就像这样

<h:inputTextArea value="#{registrationForm.comments}"/>

将HtmlInputTextArea中的value值与registrationForm对象中的comments属性动态关联起来.如果属性的类型是一个集合(List,Array,Map等),可以这样<h:graphicImage value="#{user.icons[5]}">

<h:inputText value="#{registrationForm.comments}" binding="#{registrationForm.nameInput}"/>

如果采用binding的属性,那么类的属性的类型与组件的类型要是一样的(是HtmlInputText或是HtmlInputText的子类),当需要在类中控制组件的属性的时候才使用绑定(binding).

<h:inputTextarea value="#{registrationForm.comments}"
binding
="#{registrationForm.commentsInput}"
valueChangeListener
="#{registrationForm.commentsChanged}"
validator
="#{registrationForm.checkSpelling}"
styleClass
="#{initParam[commentStyle]}"
rows
="10"
cols
="80"
title
="#{appBundle.commentsTitle}"/>

 

 

原创粉丝点击