• Post Reply Bookmark Topic Watch Topic
  • New Topic

Use static method in Facelet Page without injecting an object instance

 
Ryan Slominski
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a utility method for obtaining an array of SelectItems for a selectOneMenu component. This utility method might as well be static. Is there a way to call the utility method on the Facelets page without instantiating an instance of the bean which contains the static utility method? The bean only contains static utility methods so there is no reason to ever instantiate an instance of the bean.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"static" is actually a bit problematic in JEE. And, while I can think of some ways to do what you're proposing, they're all a lot of trouble.

A simpler way would be to make the bean be application scope. That way you have one instance, but only one instance per deployment. You wouldn't really save anything to speak of by doing anything more elaborate.
 
Ryan Slominski
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I'll stick to ApplicationScope. I assume the way to use static which is a lot of trouble is to create a custom tag. I agree that would not be worth it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!