File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dependent Drop- Down

 
Tushar Kherde
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Richard Green
Ranch Hand
Posts: 536
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.felgall.com/jstip22.htm
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Andres Quinones
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Armando Ruperez
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic