aspose file tools*
The moose likes JSF and the fly likes Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu" Watch "Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu" New topic
Author

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

Phoenix Kilimba
Ranch Hand

Joined: Oct 10, 2006
Posts: 64
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


You are what you know
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Phoenix Kilimba
Ranch Hand

Joined: Oct 10, 2006
Posts: 64
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

Joined: Jun 25, 2001
Posts: 16250
    
  21

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

Joined: Apr 08, 2003
Posts: 14
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
 
subject: Getting One Dropdown Menu Selection to Affect the Values of a Second Dropdown Menu