HTML and CSS Reference
In-Depth Information
<value>English</value>
</map-entry>
<map-entry>
<key>FR</key>
<value>French</value>
</map-entry>
</map-entries>
</managed-property>
In the XHTML page, you can display the spokenLanguages using the #{user.spokenLanguages} . If you want to
display a specific map entry value, you can get it from its key using the [] operator as well. For example, using the
#{user.spokenLanguages['EN']} will display "English" .
there is no equivalent JSF annotations for the <list-entries> and <map-entries> elements, so the only way to
initialize maps and lists is to use the faces configuration file.
Note
Managing Managed Beans Dependency
JSF supports IoC (inversion of control) for the managed beans, which means that the managed beans can be coupled
in the runtime without needing to handle this coupling from the application code. Let's see how we can utilize IoC in
our JSF applications. Listing 2-10 introduces a new property to the User managed bean, the profession property.
Listing 2-10. The New Profession Attribute in the User Managed Bean
public class User implements Serializable {
...
private Profession profession;
...
public Profession getProfession() {
return profession;
}
public void setProfession(Profession profession) {
this.profession = profession;
}
}
Listing 2-11 shows the attributes of the Profession managed bean class.
Listing 2-11. The Profession Managed Bean
public class Profession implements Serializable {
private String title;
private String industry;
public String getTitle() {
return title;
}
 
 
Search WWH ::




Custom Search