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

JSF Managed Bean Injection

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
Any idea whether we can Inject one JSF managed bean as a property into another JSF backing bean/managed bean?

I am trying to create a layer of abstraction between my backing beans and ejbs by creating a single managed bean that will have @EJB annotation to invoke the bean. This is my version of business delegate or service layer.
JSF Backing Bean -> JSF ManagedBean (Coordinator) ->EJB
 
author & internet detective
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the JSF forum. Even though you are asking due to the exam, it's a fairly specific JSF question and someone here is more likely to know.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


and


 
Kumar Amit
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M. A. Riveros T. wrote:

and




Thanks Riveros. Can I have both these managed beans as "request scoped"?

Also can i use "@EJB" annotation in "ToBeInjected" managed bean class after making request scoped.

Thanks

Amit
 
Saloon Keeper
Posts: 28320
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The rule on injection is that you can't inject an object whose lifespan is shorter than the target.

JSF is not very friendly to request-scope objects, however, so you can't use them as often as you would in most web frameworks.

Injecting EJBs into JSF backing/managed beans is possible, but rarely a good idea, since you're injecting a specific instance statically declared, and most of the time you want the EJBs to be more dynamic than that.
 
Hey! You're stepping on my hand! Help me tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic