• 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

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

 
Greenhorn
Posts: 1
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic