<f:valueChangeListener >

Hi anyone know if it is possible to

<f:valueChangeListener >

but instead of writing a class that implements ValueChangeListener

use the tag like you would use a inline ValueChangeListener

e.g

<h:selectOneMenu

valueChangeListener="#{bean1.method1}"

valueChangeListener="#{bean2.method2}"

anyone know if there is anyway i can do something like this?>

[419 byte] By [dboyd68a] at [2007-10-2 10:08:04]
# 1

In short, no. If you use the f:valueChangeListener tag you'll need a class that implements ValueChangeListener.

However, you could work around this a bit. Usually, the biggest advantage to having an inline method as opposed to a seperate listener class is that you have access to your local bean variables. So you could technically implement the ValueChangeListener interface from your bean. Nothing stops you from using the same class for two purposes (1. being the ValueChangeListener and 2. being the bean).

I wouldn't recomment this approach though. It's sloppy and more liable to break in the future. Also, you can only create one ValueChangeListener per component using this method. i.e. If you want two f:valueChangeListener tags on a single component, they both can't point to the above work around. You need one class per ValueChangeListener implementation (or start using the inline methods).

Hope this helps,

CowKIng

IamCowKinga at 2007-7-13 1:26:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Quote from the book Core JSF: "NOTE: You may wonder why you must specify a method binding when you use the actionListener and valueChangeListener attributes you must use a class name for listeners specified with f:actionListener valueChangeListener tags. The truth is that the mismatch between listener and tags was an oversight on the part of the JSF expert group."

amitteva at 2007-7-13 1:26:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...