It's not a secret anymore!*
The moose likes Struts and the fly likes JSF: Problem with valueChangeListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF: Problem with valueChangeListener" Watch "JSF: Problem with valueChangeListener" New topic
Author

JSF: Problem with valueChangeListener

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I have a form with a selectOneMenu and I have added a valueChangeListener="#{issueBean.systemChange}". And then in my backing bean I have a method:



The page loads just fine with no errors of any kind and when I change the value, select a different item in the list, the page is not being posted back to the server and I am not getting any output from my systemChange method. Am I missing a step here?


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Looking more into this, I am even wondering if changing the value of a select list will even submit the form...Hmmm. Is there any component besides the commandButton and commandLink that we can use to perform a postback?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

More reading would lead me to believe that what I expect to happen when selecting a new value is for the method to be called, resulting in a posting of the page back to itself. But it isn't happening..


Whenever they select a different set of
checkboxes, the value-change listener ColorChangeListener will be executed.


I would assume this also applies for an HtmlSelectOneMenu, am I wrong?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I think I just figured out that you actually have to supply an onchange() javascript function to the selectOneMenu and do something like document.form1.submit();. I am testing now. Is this in the book?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, it's fixed. I did have to supply an onchange() function. The only thing I can deduce is that this is something that would be generated for me if I used an IDE of some sort and setting some property like "allow postback" or something puts that function in for me. It would be nice if this was just a property of the component but since none of sun's RI Components generate Javascript, it's not gonna happen.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF: Problem with valueChangeListener
 
Similar Threads
Session scoped bean's listener invoked before request scoped bean's set method
Problem using valueChangeListener and onchange
Issue With selectOneMenu ValueChangeListener Not Firing
FacesMessages and valueChangeListener with immediate="true"
unexpected call to method or property access