This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I bean this?

 
Rob Micah
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a SessionScoped ManagedBean that holds an ArrayList of a custom class. In my facelet I reference this custom class in components. I previously had this custom class defined as a sub-class of my bean:

But the codebase for the custom class is getting complex and so I moved it to its own file. This appears to work. So my question is should I have declared this custom class as a bean since it has get/set methods and if so how would I instantiate it in my SessionScoped bean class since this will be inside a List?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17626
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CustomClass is a bean (POJO), and always has been a bean, although perhaps not literally a POJO, since it was an embedded class.

I think what you're asking is should it be a Managed Bean. And the answer to that is no.

A Managed Bean isn't a class, it's a unique instance of a class, accessible by name and constructed automatically by JSF.

Since CustomClass is not being used as a single unique instance - instead you have an entire collection of CustomClass objects, the bean management mechanisms would only apply if you went to the not-inconsiderable effort of adding a whole lot of managed CustomClass instances to your faces-config file (Annotations can't deal with multiple instances), and then fed the references to all those instances to the target bean's constructor as a managed collection property. Which is probably not going to be flexible enough for most purposes.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic