Documentation
JSFToolbox

Search 

Contents

  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
Selected 12. JSF Tag Reference

12. JSF Tag Reference

Contents > JSF Tag Reference > JSF Core Tags

10. JSF Core Tag Reference

Contents > JSF Core Tag Reference > f:valueChangeListener

f:valueChangeListener

The ValueChangeListener tag registers a ValueChangeListener instance on the component associated with the enclosing tag. The ValueChangeListener interface should be implemented by classes that you want to register with components that publish value change events.

Any component that receives user input, such as one of the HTML select or text input components, can publish value change events. A component fires a value change event when its input changes, but only if the new input is validated successfully.

You can register several ValueChangeListeners with a component and they will be invoked in the order that they are registered. An alternative to this tag is to use a method-binding expression pointing at a value change listener method of a backing bean on the component tag itself.

Notice in the example below the use of the JavaScript onchange() event to trigger form submission when the list selection changes. Without this JavaScript event, the user must manually submit the form to invoke the ValueChangeListener.

Example:

<h:selectOneMenu id="optionMenu" value="#{optionBean.selectedOption}" onchange="submit()">
  <f:selectItems value="#{optionBean.optionList}" />
  <f:valueChangeListener type="com.mycompany.MyValueChangeListenerImpl" />
</h:selectOneMenu>

HTML Output

<select name="form:optionMenu" size="1" onchange="submit()">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
</select>

Tag Attributes

type String
Required
The type attribute expects the fully qualified Java class name of a ValueChangeListener to be created and registered on the component associated with the enclosing tag.