| Author |
Difference between Managed bean and backing bean
|
Varun Nayudu
Ranch Hand
Joined: Jun 26, 2006
Posts: 156
|
|
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?
|
SCJP 1.5, SCWCD 1.5
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
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.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: Difference between Managed bean and backing bean
|
|
|