如何在JSF 2.0页面中检测字段值更改 [英] How to detect a field value change in a JSF 2.0 page
问题描述
我正在使用JSF 2.0来开发一个相当大而复杂的页面,其中包含许多字段.在页面的底部会有一个退出"命令按钮,每当用户选择退出"选项时,我都需要检测用户是否在页面的一个字段中输入了任何值.
I am using JSF 2.0 to develop a pretty big and complex page which contains numerous fields. Thre would be quit command button at the buttom of the page and when ever user selects the quit option I need to detect whether user has entered any value on one of the fields of the page.
我现在正在对后备bean中的每个字段值使用null检查来执行此操作,但这是一个非常繁琐且重复的工作.我想知道是否有任何智能解决方案?任何帮助将不胜感激.
I am using the null check of each field values in the backing bean to do that now, but that's a very tedious and repeative job. I was wondering is there any smart solution for that ?? Any help will be highly appreciated.
谢谢.
推荐答案
为此,应使用valueChangeListener
属性.
<h:inputText ... valueChangeListener="#{bean.changed}" />
使用
public void changed(ValueChangeEvent event) {
this.changed = true;
}
这篇关于如何在JSF 2.0页面中检测字段值更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!