Forums Register Login

Difference between Managed bean and backing bean

+Pie Number of slices to send: Send
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?
1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 11993 times.
Similar Threads
JSF Backing Bean in Java EE 6
backing bean and managed bean-difference?
JSF Portlet and instance variables
Backing bean vs Managed bean
backing beans vs managed beans
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:37:04.