Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect a field value change in a JSF 2.0 page

Tags:

jsf-2

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.

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.

Thanks in advance.

like image 979
user1220373 Avatar asked Mar 05 '12 08:03

user1220373


1 Answers

For that the valueChangeListener attribute is meant to be used.

<h:inputText ... valueChangeListener="#{bean.changed}" />

with

public void changed(ValueChangeEvent event) {
    this.changed = true;
}
like image 166
BalusC Avatar answered Oct 02 '22 16:10

BalusC