Common annotations of JSF

Source: Internet
Author: User
@ManagedBean

registers a class instance as a managed bean, and then puts it in the use of one of the @ ... Within the range specified by the Scoped annotation. If no scope is specified, JSF puts the bean into the request scope, and if no name is specified, JSF converts the first letter of the class name to lowercase to form a managed bean name; For example, if the class name is UserBean, JSF creates a managed bean, Its name is Userbean. The eager and name properties are optional.

Note You must use a Java class that implements a zero-parameter constructor in combination. @ManagedProperty set a property for the managed bean. Annotations must be placed before the declaration of a class member variable. The Name property specifies the names of the attributes, which by default are the names of the member variables. The Value property is the values of the attribute, can be a string, or it can be a JSF expression, such as #{...}.     @RequestScope Store managed beans within the scope of the request. @SessionScoped Store managed beans in session scope. @ApplicationScope store managed beans on an application-wide scale. @ViewScope Store managed beans in view scope. the @NoneScope Specifies that the managed bean has no scope. A managed bean with no scope is more useful when it is referenced by another bean. @CustomScope

store managed beans within a custom scope.

a custom scope is a map that can be accessed by the creator of the page. You can programmatically control the visibility and lifecycle of a bean within a custom scope. The Value property points to a map. @PostConstruct used after resource injection initialization @PreDestory for servlet detach service and release injected resources @ Resource is in a class or variable to "resource injection" of the servlet container. When the container recognizes this annotation, it implements the re-injection of the annotated variable with the appropriate value before obtaining the service status. By using this annotation, you do not have to use Jndi to find commands and manually declare resources in the configuration file Web.xml. The server performs its tasks through a servlet's self-regulation. The name and type of the variable are automatically determined by the imaging mechanism, although you can use the parameters of the annotation to override this limitation. An injected resource can be a data source, a Java Information service destination file, or a scalar that is set by the environment. @Resources for a set of @resource annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.