• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

valueChangeListener

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



or is the syntax



without the pound sign and brackets?

Thanks,
Jim
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also new to JSF but I have done something like this before.

<h:selectBooleanCheckbox ... valueChangeListener="#{bean.someValueChanged}" />

hope this helps.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Selecting a value in box #1 submits the page's form (via JavaScript onchange) which then triggers the handleBox1ValueChange method to be executed. In that method, I want to issue a JDBC query using the value in box #1 to get list items for box #2.

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.

Boxes #2 and 3 each have a JavaScript onchange to submit the form and each have a handleBoxXValueChange method.

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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic