Two Laptop Bag
The moose likes Struts and the fly likes JSF: Problem with valueChangeListener Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "JSF: Problem with valueChangeListener" Watch "JSF: Problem with valueChangeListener" New topic
Author

JSF: Problem with valueChangeListener

Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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?
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF: Problem with valueChangeListener
 
Similar Threads
FacesMessages and valueChangeListener with immediate="true"
Problem using valueChangeListener and onchange
Session scoped bean's listener invoked before request scoped bean's set method
Issue With selectOneMenu ValueChangeListener Not Firing
unexpected call to method or property access