Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf2, richfaces4, multiple selects depending on each other, valueChangeListener not called  RSS feed

 
Richard Osz
Greenhorn
Posts: 1
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Richfaces and Jsf2 in general, and I hope I am not asking a question with an obvious answer

I am trying to use four rich:select elements, each ones content depending on the value selected in the one before. The problem I am having is that this works ok for the first and second select, but the third and fourth are not updated.

Here is my form:



And here is my backing bean:



I can see by the debug println statements that the valueChangeListener method for the second select is not called, so the list of values for the third select is not populated.

Any thougths?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Richard!

I'm not familiar with a4j:ajax. Possibly it's new to RichFaces 4, which I haven't been brave enough to attempt yet. I use a4j:support.

What works for me is that I make the valueChangeListeners do a minimal amount of work. They zap the selected value for the lower-level control (since the old value may not apply anymore), and they zap the selectItems list that goes with that lower-level control. The "getselectitems" method for the lower-level control uses a cached approach, where if the list was zapped, I rebuild it (based on the new higher-level values) and save it so that I don't repeat the process more often than strictly necessary.

One thing that you should do, however, is cascade the zapping process, since by definition invalidating a higher level invalidates all its lower levels. Don't depend on JSF to do that for you, since if you didn't change the lower-level values on the client side before submitting the form, their valuechangelisteners won't fire. The VCL controller simply compare what's in the bean to what's in the incoming data and only fire if those 2 values are different.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!