• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Difference between Managed bean and backing bean

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have a question.

What is the difference between managed bean and backing bean?

I got the following answers googling but couldnt understand it

Ans1: Managed bean and backing bean are the same. Managed bean is about how the bean is initialised and created, where as backing bean is what role it plays a particular managed bean plays.
Managed bean are java bean that are registered in the faces-config.xml and there properties are binded to the UIcomponent values.
Backing bean are special type of managed beans whose properties are UIcomponent.



Are Backing beans not registered in the faces-config.xml ?

And the answer which i found if correct can anybody please explain?
 
Saloon Keeper
Posts: 28761
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That answer is garbage. A backing bean can be a POJO, not some sort of JSF-specific object with JSF-specific properties (such as UIComponent). In fact, backing beans, generally should be POJOs, at least as much as possible. This whole nonsense about using binding is, as far as I can tell, leftover stale documentation and mythologies from when JSF was still being designed and no one had a better way. Binding is not needed very often these days.

When you declare a bean in faces-config.xml (or as a ManagedBean annotation), you are declaring to JSF that you want JSF to manage an instance of this Bean, and part of the faces-config description of that bean is the name that the bean will be managed under. Same thing with the ManagedBean annotation, although the annotation can assume a default name based on the bean's classname if you don't provide an explicit name.

A backing bean is simply a bean that's referenced from a JSF View. Technically, you could construct all your backing beans the hard way in servlets and store them in Session or Application attributes (Request scope is harder to do that way). But it's easier to make the backing beans be Managed Beans so that JSF does the job for you.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Managed Bean is declared in FacesConfig.xml file and is available for all of the application.
Backing Bean which is declared in adfcConfig.xml is Hardcoded to a particular JSF page. Backing bean is Module Specific.
 
Tim Holloway
Saloon Keeper
Posts: 28761
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Navpreet Sidhu wrote:Managed Bean is declared in FacesConfig.xml file and is available for all of the application.
Backing Bean which is declared in adfcConfig.xml is Hardcoded to a particular JSF page. Backing bean is Module Specific.



Sorry. That is not correct.

A Managed Bean is a POJO that is constructed by JSF on-demand. It is defined by faces-config.xml (or whatever override name(s) you configure into web.xml).

A Backing Bean is a POJO that is referenced by one or more JSF View Definitions. The relationship between Views and Backing Beans is not 1-to-1, it's many-to-many. A single View can (and often does) reference more than one backing bean, and a single backing bean may be referenced by more than one View.

Backing Beans are almost always Managed Beans and vice versa, since JSF uses the Managed Bean functionality to construct Backing Beans as needed on demand.

But I doubt any of the original participants in this discussion are interested anymore. This thread was last updated in 2011 and they've probably moved on.
 
reply
    Bookmark Topic Watch Topic
  • New Topic