I have two beans. First bean languageOfSystem:
@Named(value = "languageOfSystem")
@SessionScoped
public class LanguageOfSystem implements Serializable {
@Inject private JsfUtils eeJsfUtils;
and the second bean, userBb:
@Named(value = "userBb")
@SessionScoped
public class UserBb implements Serializable, LangUpdInterface {
@EJB
private EjbUtils ejbUtils;
@EJB
private PuserFacade puserFacade;
@Inject
private Direction direction;
@Inject
private PortfelDao portfelDao;
@Inject
private LanguageOfSystem languageOfSystem;
I inject languageOfSystem into userBb, and NetBeans IDE gives me warning in line with that injection:
no enabled eligible for injection beans are found
But I’m able to call methods from languageOfSystem in userBb and it works fine. So is this warning important and should I change smth?
And the second question. I use in this case observer design pattern, where userBb is dependent and languageOfSystem is the subject which has a list of dependents. I register userBb in subject list by calling appropriate method from languageOfSystem. Is it right when it comes to the two session beans?
Your code does not look wrong – and it works. So this seems to be a Netbeans issues.
Are you aware that the CDI spec includes a powerful and typesafe implementation of the observer pattern? You definitely should check this out.
And two more things to mention here:
out and simply write
@Namedinstead.@Namedis not required at all –all it does is providing an EL name for use in JSF. Your code will
work just as good if you skip @Named altogether…