Java Reference
In-Depth Information
Named beans
In the earlier section, we came across the @Named annotation. Named beans allow us to
easily inject our beans into other classes that depend on them and refer to them from JSF
pages via the Unified Expression Language ( UEL ). Recall the earlier example:
@RequestScoped
@Named
public class Customer {
private String name;
private String surname;
public String getName(){
return name;
}
public String getSurname(){
return surname;
}
}
This class, decorated with the @Named annotation, can then be referenced from a JSF
page:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html ">
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="name" value="Name" />
<h:inputText id="name" value="#{customer.name}"
/>
Search WWH ::




Custom Search