In the jee6 tutorial, I can read the following:
The @Named qualifier allows you to access a bean using the name bean, with the first letter in lowercase. For example, the Facelets Page will refer to the bean as a printer.
You can specify an argument for the @Named classifier to use a nondefault name:
However, when I try to use @Named without adding an argument, My bean cannot be found, and I get an exception, as shown below.
@Named
@ViewScoped
public class MTestBean {
...
}
An exception;
javax.servlet.ServletException: /MyPage.xhtml @15,65 listener="#{mTestBean.init}": Target Unreachable, identifier 'mTestBean' resolved to null
But if I use
@Named("mTestBean")
Everything works perfectly. Is this expected behavior? Is there any way I can list that beans are available in EL, maybe I am assuming the wrong default name?