Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract jsf managed bean injecting abstract facade  RSS feed

 
daniele licitra
Ranch Hand
Posts: 81
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm implementing an MVC application.
I want to "inject" EJB in a dinamic way inside a jsf managed bean.

In details:

Entity:


Facade for controllers:



and a backing bean in jsf for View:



Entity and Facade are ok, the problem is "ModuloJSFAstratto":


How can I set the facade dynamically?

Option 1- I can use @EJB in ModuloJSFAbstract implementation (ViewApplicazioni) , but "How can I refer to the injected ejb in the abstract class?"

Option 2- I can lookup EJB from context passing the jndi name in constructor:

but this system return java.sun.Proxy object and i cannot cast it to my facade How can i resolve this casting problem?

Thank you in advance
 
daniele licitra
Ranch Hand
Posts: 81
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved! Using option 2, i need to cast the lookuped ejb to his interface, not to the implementation.

So F now is not of type AbstractFacade but InterfaceFacadeRemote and in ViewApplicazioni became

@SessionScoped
public class ViewApplicazioni extends ModuloJSFAstratto<Applicazioni,ApplicazioniRemoteInterface>{
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!