File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF 2.0 selectOneMenu control not populated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 2.0 selectOneMenu control not populated" Watch "JSF 2.0 selectOneMenu control not populated" New topic
Author

JSF 2.0 selectOneMenu control not populated

adam smith ii
Greenhorn

Joined: Feb 04, 2010
Posts: 20
Hello,
Am new to JSF 2.0 and JSF web apps in general. PlaceOrders.xhtml has a drop down control <h:selectOneMenu value="#{placeOrders.growersWithOrders}">
that I am trying to get populated before the page is initially displayed.

Tried a @PostConstruct in the backing bean method to populate the backing bean property - to no effect. Tried this based on another thread i read.

Also tried to populate the backing bean property after the page was displayed using the <h:commandButton action="#{placeOrders.buttonRefreshSupplierOrders}"
button, also to no affect.

Have println displays that appears to show that the growersWithOrders ArrayList has intended content.

Also tried to populate backing bean property in backing bean constructor, but got a nullPointerExecption on the entityManager.

Thanks in advance.

PlaceOrders.xhtml

PlaceOrders.java

SalesrecordsFacade.java

Display listing based on above code:
adam smith ii
Greenhorn

Joined: Feb 04, 2010
Posts: 20
Hello all,
The problem with the drop down control not being populated dealt with the use of the values associated with the page elements.

The h:selectOneMenu was wrongly associated with an ArrayList. It should have been associated with a String value that holds the selected value.

Likewise, for the associated page element, f:selectItems - it was wrongly associated with a String. It should have been associated with an ArrayList that holds the list of values.

There is still an issue of the ArrayList, which is based on resource injection that pulls from the database not being available when the backing bean is constructed.

Thanks to all that read
adam smith ii
Greenhorn

Joined: Feb 04, 2010
Posts: 20
Hey,
@PostConstruct in the backing bean method to populate the backing bean property DOES work

Issue was I just didn't know it because the information failed to appear on the form, see solution to that above.

Thanks all for your participation and the sharing of your knowledge.

 
 
subject: JSF 2.0 selectOneMenu control not populated