*
The moose likes Struts and the fly likes JSF: Show me a better way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF: Show me a better way" Watch "JSF: Show me a better way" New topic
Author

JSF: Show me a better way

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I am filling list boxes with data from a database. Nothing new there. But it seems really messy the way I am doing it now. I have a list that holds a list of hardware items (motherboard, harddrive, etc). I am using Hibernate so this is my method to retrieve my list:



This return a java.util.List of Hardware objects. I return that list to one of my backing beans and in order to fill the list I have this method:



And then in my JSF page



My getHardwareList method is the nastiest thing I have seen in a while. Is there a better way to do this?


GenRocket - Experts at Building Test Data
Dave Wood
bronco
Ranch Hand

Joined: Aug 02, 2004
Posts: 161
I think that's pretty much what you need...though it might be a bit less ugly like this...



or, better yet, in Tiger:





Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Thanks Dave. I will give that a shot. The Tiger way looks best to me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSF: Show me a better way
 
Similar Threads
problem while setting default value for h:selectOneMenu
Dropdown creation dynamically from DB lookup
DropDown Menu error in Struts 2
JSF drop down.
How to set default selection for selectOneMenu?