File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu

 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Esteemed Sirs et Madames,
I have 6 dropdown menus on the same Visual Web JSF page (Zone,Region,District,Facility,Year,Quarter). I need for it to be such that only when I make a zone selection should the region selection be populated with regions that are found within that particular zone selected in the zone dropdown menu. The same again with the district dropdown, it should only be populated once a region has been chosen so that the districts available for selection reflect the region.... and so on for the rest of the dropdowns. How can I go about this please?

Thanking you profusely in advance
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17627
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use a JSF tagset that supports AJAX you can do this fairly easily. I've got an app that uses RichFaces to do exactly that kind of menu cascading.
 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks Tim, is there a way of using the current set up without getting into AJAX? AM using Visual Web JSF. Incidentally what would be the overhead of learning and using AJAX for this particular issue, and could I get your code for the cascading dropdown menus as a reference point?
Thanks
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17627
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AJAX isn't required, but if you don't use AJAX, you have to reload the entire page each time you change one of the menus. The basic code is the same in either case - when a parent menu changes, you replace the datamodel for the child menu(s).

I haven't used NetBeans, and in any event, it's not the IDE that's got to work, it's the code.

Here's a snippet of some RichFaces JSF with AJAX-enabled cascading menus:


There isn't any AJAX code you have to write. The "a4j:support" tag manages the AJAX - it detects the "onchange" event on the menu and fires the valueChangeListeners in the backing bean. The ValueChangeListeners cause the datamodels for that menu's children to be reset. The reRender attributes limits the actual page updating to only those items named (matching "id" attributes) Otherwise the whole page gets refreshed.
 
kit james
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the snippet that you post only works in session scope isnt it ?
will it work in request scope ? I try to get it to work with t:saveState yet it does not work.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic