HTML and CSS Reference
In-Depth Information
@Named
@SessionScoped
public class User implements Serializable {
private String name;
private String password;
@Inject
private Profession profession;
// ...
public Profession getProfession() {
return profession;
}
public void setProfession(Profession profession) {
this.profession = profession;
}
//...
}
We need to note some changes that should be made in order to use CDI with our User managed bean:
The
@Named annotation replaces the @ManagedBean annotation.
We used the
javax.enterprise.context.SessionScoped instead of the javax.faces.bean
.SessionScoped (in CDI, you must not use the javax.faces.bean.xxx package for specifying
the bean scope; instead, you have to use the javax.enterprise.context.xxx package).
We used the
@inject annotation for injecting the Profession managed bean instance in the
User managed bean instance instead of using the @ManagedProperty annotation.
Note
When using CdI, you need to create an empty beans.xml under the WEB-INF folder of the web application.
Expression Language
There are two different sets of ELs:
The JSP EL.
There are many differences between the two ELs. The JSP EL expressions start with the dollar sign ( $ ), then
followed by the left curly bracket ( { ), then followed by the JSP expression, and finally closed with the right curly
bracket ( } ). The JSP EL executes immediately when the page is rendered (in the page compilation time). On the other
hand, the JSF EL expressions start with the hash ( # ), then followed by the left curly bracket ( { ), then followed by the
JSF expression, and finally closed with the right curly bracket ( } ). The JSF EL expressions execution is deferred, which
means that the expressions are evaluated based on the JSF lifecycle context.
To be more specific, the JSF deferred expressions are available during the page postback as well as the page initial
rendering, which means that the JSF deferred expressions can be evaluated in the request processing and the
response rendering phases of the JSF framework, while the JSP immediate expressions are available ONLY during the
The JSF EL.
 
 
Search WWH ::




Custom Search