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

How to display a list of strings

 
Greenhorn
Posts: 10
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have figured out, how to diplay basic datatypes of an entity / object in a dataTable, but I can't find a way to display a List<String>.

I also tried it with ui:repeat, but the space, where it should appear, stays empty. This is my code right now:

Product.java (the entity)


and the page: index.xhtml



This is probably not very hard to do, but there are somehow no good examples on the internet for this.

Thank you in advance!
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're mis-using the term "datatype". In the case of rows of a dataTable, what you seem to be calling its "datatypes" would actually be the values of the row item's properties. For the list, there are no properties as such, so it's simple the list values you want to display.

I cannot think offhand why what you are proposing wouldn't work as long as the neededResources property of Product was populated with list values. Although it's generally not possible to make an ORM model object serve directly as a JSF backing bean GUI model object, since the JSF bean manager doesn't have the ability to either locate a specific persistence model object instance or to retrieve it and map it.

One thing I do recommend is that instead of a simple EL expression to output the value, use the h:outputText element. It won't solve the problem of getting a value, but it will at least allow JSF to more cleanly integrate that value into its component tree. Plus, of course, add support for stuff like CSS styling.
 
Fred Funks
Greenhorn
Posts: 10
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim Holloway,

thank you for your reply. Sorry, that I answer only now.

As i suspected, the way I tried to display the list of strings was right. What I didn't know, is that such a list of an entity-class doesn't get loaded automatically, when an instance of that class does. So, I set the fetchType of that list to 'Eager' and now it gets displayed on my page :)
 
reply
    Bookmark Topic Watch Topic
  • New Topic