• 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

Dependent Drop- Down

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I have problem regarding Dependent Drop-Down.
For Example i have drop-down for country, as soon as i select country, drop-down for state should get populate.

Any suggestion or sample code
thanks in advance
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.felgall.com/jstip22.htm
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just one line of code with Ajax4jsf.

Example:
http://livedemo.exadel.com/a4j-dropDownBoxes/

Source code:
https://ajax4jsf.dev.java.net/nonav/ajax/ajax-jsf/download.html#examples
 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply

I cant use javascriprt because i am populating 2nd dropdown from database and not using ajax also.
Cant we do this using plain JSF on some event, if we render the whole page again.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tushar Kherde:
Thanks for reply

I cant use javascriprt because i am populating 2nd dropdown from database and not using ajax also.
Cant we do this using plain JSF on some event, if we render the whole page again.



You can do it this way
<h:selectOneMenu valueChangeListener="#{Bean.listenerMethod}" onchange="submit()" value="#{Bean.value}">
<f:selectItems value="#{Bean.list}"/>
</h:selectOneMenu>
And in the Bean you only need to add a method like this
public void listenerMethod( ValueChangeEvent e ) throws AbortProcessingException{
Object value = e.getNewValue();
}

There you will have the value you selected in the list and you can use it to populate the other dropdown.

I hope this helps
[ February 14, 2007: Message edited by: Andres Quinones ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andres Quinones wrote:

Originally posted by Tushar Kherde:
Thanks for reply

I cant use javascriprt because i am populating 2nd dropdown from database and not using ajax also.
Cant we do this using plain JSF on some event, if we render the whole page again.



You can do it this way
<h:selectOneMenu valueChangeListener="#{Bean.listenerMethod}" onchange="submit()" value="#{Bean.value}">
<f:selectItems value="#{Bean.list}"/>
</h:selectOneMenu>
And in the Bean you only need to add a method like this
public void listenerMethod( ValueChangeEvent e ) throws AbortProcessingException{
Object value = e.getNewValue();
}

There you will have the value you selected in the list and you can use it to populate the other dropdown.

I hope this helps
[ February 14, 2007: Message edited by: Andres Quinones ]




I'm trying to follow this suggestion but, it doesn´t seem to work, throws a null pointer exception unless y put the rendered="#{GlobalData.selectClient!=null}" option in the second selectOneListbox, and if that is the case, after the selection of the first listbox is made, the second one never shows up.

Is something im missing?, perhaps someone can help me.
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic