This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF 2.0 selectOneMenu control not populated

 
adam smith ii
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic