Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF: Problem with valueChangeListener

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic