Codes for this article
Video Demonstration for this article
- Target: Intermediate level programmers and web-developers. Any programmer/web-developer can take a look.
- Pre-requisite: HTML, JSP, Servlet, Tomcat, J2EE, MVC, and JSF Introduction. Check the corresponding sections of this web-site, to have an idea on the required technology knowledge
- Pre-requisite: Download this sample JSF application
- Beans used by JSF enabled applications are called managed beans as they are created and managed by JSF
- JSF is based on the MVC architecture where beans provide the models
- To be used with JSF, a bean must have a no argument constructor. The bean can expose its properties with get or set methods for reading or writing from outside
- Beans can be used in two ways in JSF applications: The information required to create managed beans are provided in the configuration file (faces-config.xml), JSF uses value binding expressions or method binding expressions, to refer to the properties of the managed beans.
- Configuring Managed Beans
- Beans are configured in the faces-config.xml file. The file is usually provided under WEB-INF folder. Though from the web.xml file (using the javax.faces.CONFIG_FILES context parameter), you can refer to any other file where the configuration is provided.
- META-INF/faces-config.xml file can also be used
- Multiple configuration files can also be used. The file names should be mentioned in the web.xml file.
- Initialize Bean Properties
- Tags such as, value, null-value, list-entries, map-entries can be used to initialize bean properties in the configuration file. value can be used to set String type parameter, null-value is used to set an Object type property to null, list-entries is used to initialize a List type property, map-entries is used to initialize a Map type property. Check this file for examples – the target audience I assume have the background to understand it just by checking
- Accessing Bean properties
- Bind managed bean methods to expressions in JSP pages
- or : set flight property as the control is a JSF input control
- or : Retrieve value from the origin property.
- Access list property values: #{bus.times[“1”]}
- Access Map property values: flight.airportNames.key, flight.airportNames[key]
- Similarly, you can also bind managed bean methods to expressions in JSP pages.
From: http://sitestree.com/?p=4993
Categories:Java Short Notes
Tags:
Post Data:2010-10-14 11:11:25
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada