• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to fill an selectOneMenu and selectManyMenu from my database and retrieve the option selected

Tom Ram
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to programming world
I want to fill an selectOneMenu and selectManyMenu from my database.
I have found a simple of code that fill selectonemenu , so I have cutomised it to my need . but I haven't really understand it, I dont know how to retrieve the choice done by the user. (For selectManyMenu I dont know how to do that)
Do I need a button to validate to retrieve data choosed , because I nees the option choosed as a parameter for another request.
the code is:
<h:selectOneMenu value=" #{BeanSelectItem.maValeur}" >
<f:selectItems value="#{BeanSelectItem.mesElements}"/>
<hutputLabel value="#{BeanSelectItem.maValeur}" />



public class BeanSelectItem {
private List<SelectItem> mesElements;
private String maValeur;

public String getMaValeur() {
return maValeur;

public void setMaValeur(String maValeur) {
this.maValeur = maValeur;

public void setMesElements(List<SelectItem> mesElements) {
this.mesElements = mesElements;

public Iterable<String> remplireItem() throws ClassNotFoundException, SQLException
Connection con = DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe"," "," ");
PreparedStatement statement = con.prepareStatement("SELECT pname from issuestatus");
ResultSet rs = statement.executeQuery();
String var;
ArrayList<String> list = new ArrayList<String>();
var= rs.getString("pname");


return list;

public List<SelectItem> getMesElements() throws SQLException, ClassNotFoundException {

if (mesElements == null) {
mesElements = new ArrayList<SelectItem>();
for (String val : remplireItem()) {
mesElements.add(new SelectItem(val));
return mesElements;


Thank you
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic