• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

selectOneMenu from database

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Why my code doesn't works? After code execution on JSP page I get empty selectOneMenu. Please help me!

Page: test1.jsp:

<html>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<f:view>
<head>
<link href="styles.css" rel="stylesheet" type="text/css"/>
<title>

</title>
</head>
<body>
<h:form >

<h:selectOneMenu value="#{test1.value}">
<f:selectItems value="#{test1.values}" />
</h:selectOneMenu>

</h:form>
</body>
</f:view>
</html>

Bean: Test1.java


faces-config.xml:

<managed-bean>
<managed-bean-name>test1</managed-bean-name>
<managed-bean-class>com.va.epms.dept.Test1</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably are not seeing the menu labels on the page. Try this:
SelectItem(java.lang.Object value, java.lang.String label)
instead of this:
SelectItem(java.lang.Object value).
This will construct a SelectItem with the specified value and label.

Also from the code I could not figure out if you are calling the getNames() anywhere. Did you verify that this method gets called and the resultset is not empty?
[ October 31, 2007: Message edited by: A. Dusi ]
 
Ivann Ivanoff
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks A. Dusi !

With pleasure would look at a similar working code, (code must work with database) !!!
 
Ivann Ivanoff
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, I solved this broblem. My implementation isn't perfect, but he works!

Bean: Test1.java

 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic