DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Coding
  3. Frameworks
  4. Declaring managed beans in JSF 2.0

Declaring managed beans in JSF 2.0

A. Programmer user avatar by
A. Programmer
·
Jun. 30, 11 · Interview
Like (0)
Save
Tweet
Share
8.98K Views

Join the DZone community and get the full member experience.

Join For Free

In the next example we will see how to declare a managed bean in JSF 2.0. There are two ways to configure the managed bean :

1. Declaring a Managed Bean in faces-config.xml descriptor file as below:

<managed-bean> 
    <description>description of the managed bean</description>
    <managed-bean-name>name of the managed bean</managed-bean-name>
    <managed-bean-class>fully qualified class name</managed-bean-class>
    <managed-bean-scope>scope of the bean</managed-bean-scope>
    <managed-bean-property>
        <property-name>name of the bean property</property-name>
        <value>Default value of the property</value>
    </managed-bean-property>
    ...
</managed-bean> 
2. In JSF 2.0, you can annotated a Java class with @ManagedBean annotation to turn it into a Managed Bean:
@ManagedBean
public class MyBean ...

In addition, you can customize the bean name, by adding the name clause to the annotation:

@ManagedBean(name=”CustomName”)
public class MyBean ..

From http://e-blog-java.blogspot.com/2011/06/declaring-managed-beans-in-jsf-20.html

Bean (software) Spring Framework

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Software Developer Competencies: How To Recognize a Good Programmer
  • Testing Repository Adapters With Hexagonal Architecture
  • Java Code Review Solution
  • Understanding and Solving the AWS Lambda Cold Start Problem

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: