Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic drop down menus with javascript  RSS feed

 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I need to have a list of categories to choose from in a dropdown menu that will populate a second menu with options, and have the value of the option selected in the second menu bound to a variable in a bean. Is this possible with JSF and if so, can someone give me some pointers? Thanks.
 
Ravisekhar Kopparthi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is very much possible.
Lets say you have dropdown1 and dropdown2 in your page.

When you select dropdown1 get the value of it in backing bean
do your query to retrieve options for drop down to and set it in sessionScope.

Have the second drop down point to this variable in sessionScope
like this
<h:select id="options" value="#{sessionScope.options}" >


Now to bind this option back to JavaBean is very easy
again when a submit event is fired in the backing bean method
get the value of dropdown2 and set it on a JavaBean.

Hope this helps.

Thanks
Ravisekhar Kopparthi
 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but I have actually already done that. What I need to know is how to do it with *Javascript* client-side instead of having to refresh the page each time the first listbox is changed. How can I do this?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!