This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
If I want to bind a valueChangeListener to a textbox, do I have to bind this to a class that implements ValueChangeListener (as in the example in http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFPage8.html) or can I bind it to a method on a managed bean (one that does not implement ValueChangeListener)?
Further, does the syntax for valueChange listener include the pound sign and brackets as in
So does the bean class (the class to which the method someValueChanged is a member of) have to implement ValueChangeListener? I've seen some examples of where it does...others where it doesn't. I'm not sure if it varies between versions (1.0 versus 1.1).
Originally posted by James Ellis: So does the bean class (the class to which the method someValueChanged is a member of) have to implement ValueChangeListener? I've seen some examples of where it does...others where it doesn't. I'm not sure if it varies between versions (1.0 versus 1.1).
No, you can either create a class that extends ValueChangeListener and implement your methods there or you can use the backing-bean with a valueChange method and use that.
This is right down the same alley that I am perplexed over.
I have a page with 3 combo-boxes (selectOneMenu) on it. They are interrelated. By that I mean initially, box #1 is initialized and enabled while boxes #2 & 3 are disabled. There also is a submit button labeled "Go" which has a doGoBtnAction method.
IF the list for box #2 comes back with only one item, I want to go ahead and issue a JDBC query for box #3 using the values from boxes #1 and 2. Otherwise, box #3 remains disabled.
Assume box #2 only had one list item so now box #3 is populated and enabled. The goofy thing I'm seeing is that if I now make a selection in box #3, when the form gets submitted, JSF executes the handleBox2ValueChange method instead of the handleBox3ValueChange.
The same would occur if I clicked the "Go" button to submit the form. Initially, the handleBox2ValueChange method would execute, THEN the doGoBtnAction method.
What makes it even weirder (to me, anyway) is the values that are stored in the valueChangeEvent newValue and oldValue properties. They are NOT necessarily the previous and current values in the combo-box!! Sometimes they're a value or two behind (i.e. the 'oldValue' is two selections ago, the 'newValue' is the previous selection, not what's currently in the combo-box).
So.......that's a lot of detail and background to get to my question, which is this:
Does anyone know where JSF stores the 'oldValue' or what it uses as the oldValue to compare with the 'newValue'? And where is that newValue obtained from since like I said, it's not always what I have currently selected.
All the combo-boxes are mapped to a property in a bean with a scope of session. The backing bean used on my page retrieves those values in the beginning.
I'm really confused and I hope this explanation makes some sense.
Thanks for your help, Matt [ September 06, 2005: Message edited by: Matt Lehning ]