File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Managed bean and backing bean

 
Varun Nayudu
Ranch Hand
Posts: 159
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17620
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • 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.
 
Navpreet Sidhu
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 17620
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic