This discussion is archived
14 Replies Latest reply: Oct 26, 2012 2:52 AM by gimbal2 RSS

Differences between JSF managed bean and back bean

925716 Newbie
Currently Being Moderated
Is the difference between JSF Managed Bean and Back Bean is only about the scopes are any differences in action ?

I read something about the back bean and Managed bean can be work as is, somehow managed bean can be act for both operations controller and form bean to store and render the values to JSF page.

And one more i found, the scope for the back bean will be applicable to request only, where as we can give application, session, request scopes to the Managed bean.

Clear me on my understandings....?
  • 1. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    Its just terminology. In JSF you have server side components which are often referred to as "managed beans" or "backing beans". Managed bean is more of a JSF specific term while 'backing bean' is used more consistently across different web frameworks.
  • 2. Re: Differences between JSF managed bean and back bean
    963137 Newbie
    Currently Being Moderated
    Managed bean contains getter and setter methods for handling the data entered in the web form, where as a Backing bean contains some or all component
    objects of a web form for manupulating the ui components form code.
  • 3. Re: Differences between JSF managed bean and back bean
    EJP Guru
    Currently Being Moderated
    Managed bean contains getter and setter methods for handling the data entered in the web form, where as a Backing bean contains some or all component objects of a web form for manupulating the ui components form code.
    Most people would say you have that back to front if anything, but a backing bean would be entirely unable to do what you say unless it were also a managed bean.

    A managed bean is simply a bean which is brought into existence automatically by the framework.
  • 4. Re: Differences between JSF managed bean and back bean
    905019 Newbie
    Currently Being Moderated
    Hopefully the next EE spec will clarify the managed bean concept as currently CDI and JSF both has them (next rev of JAX-RS also?)
  • 5. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    Nik wrote:
    Hopefully the next EE spec will clarify the managed bean concept as currently CDI and JSF both has them (next rev of JAX-RS also?)
    Its 'not clear' because there are now two ways of doing it; the old JSF way or the new CDI way. Choice tends to muddy the water, no amount of documentation is going to stop people from getting confused.
  • 6. Re: Differences between JSF managed bean and back bean
    905019 Newbie
    Currently Being Moderated
    Choice must be taken away then ;-) Worst is probably the use of the common names for the CDI/JSF scope annotations.
  • 7. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    No it must not, because that breaks all existing applications. Backwards compatibility is a b1tch. You can opt to leave it out of the specs, but then all of a sudden you have all these valid annotations which are not documented but WILL pop up in existing code and articles.

    Nope. Programming is hard. Always has been. Always will be. Good thing too, otherwise anyone could do it and we would be out of luck.
  • 8. Re: Differences between JSF managed bean and back bean
    905019 Newbie
    Currently Being Moderated
    The whole platform would need a backward-compatibility-breaking branch where all the cruft (multiple I/O implementations in the RT etc) would be purged.
  • 9. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    Basically that becomes a new platform and an alternative to the existing one.

    http://xkcd.com/927

    It is not going to happen, but Oracle is (slowly) moving towards modularization which can be used to selectively filter out some of the cruft. It will no longer be a platform choice, but a deployment one. Unfortunately the tech keeps being pushed back.
  • 10. Re: Differences between JSF managed bean and back bean
    905019 Newbie
    Currently Being Moderated
    Off topic but what the hell...

    I think the migration path from the old one to the new could be made smootish. The old apps could run as before. New apps could be written for the new platform. Those who wish to migrate an app would have well documented (and tooled) approaches.

    And regarding the pushback, I understand that the cloud-thingie got axed because nobody knows yet where it's going but I was a bit disappointed by the module-axe since I thought the problem was pretty well understood with OSGI, JBoss Modules etc etc
  • 11. Re: Differences between JSF managed bean and back bean
    jmsjr Newbie
    Currently Being Moderated
    gimbal2 wrote:
    Nik wrote:
    Hopefully the next EE spec will clarify the managed bean concept as currently CDI and JSF both has them (next rev of JAX-RS also?)
    Its 'not clear' because there are now two ways of doing it; the old JSF way or the new CDI way. Choice tends to muddy the water, no amount of documentation is going to stop people from getting confused.
    Count me in as one who is confused with the backing bean vs managed bean terminology. From what I gather here:

    Managed bean is automagically created by the framework ( hence managed ) with the possibility of CDI,
    So where does that leave the backing bean ?

    The JSF tutorials I see online have the managed beans to "work" as well ( the managed bean have a method called by the <h:commandButton action="#{managedBean.doSomeWork}"/> ), so that makes them backing beans as well ?

    What is the "old JSF way" referred to here ?
    And what is the "new CDI way" ?
  • 12. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    When talking about JSF they are still the same thing, only two different names for the same beast. Its a "backing bean", conceptually it is a Java bean which is used to 'back' something else, generally a web front-end. That term is used in most web related frameworks. As EJP already mentioned JSF manages those backing beans internally and makes sure they exist when they need to exist, you can refer to them in a unified manner (through an EL expression) and that they can be injected where you need them; hence they are often referred to as "JSF managed beans".

    This thread got really muddy when CDI was coined, which is related in a way but does not have any real kind of influence over terminology. CDI provides an alternative and more unified way to REFER to beans that can exist within an application, making it easier to wire them up together. CDI is the JEE wide specification, not specific for JSF. But since JSF falls under the JEE specification you can use CDI in combination with it as well. In JEE5 and down you'd need a wide variety of annotations to do it (@ManagedBean, @ManagedProperty, @Stateless, @Stateful, @EJB, @Resource, @PersistenceContext, ...) whereas using CDI you can use the same annotations everywhere. On top of that CDI was designed to be able to use it outside of a JEE container also.
  • 13. Re: Differences between JSF managed bean and back bean
    EJP Guru
    Currently Being Moderated
    I think the migration path from the old one to the new could be made smootish. The old apps could run as before. New apps could be written for the new platform. Those who wish to migrate an app would have well documented (and tooled) approaches.
    So those running the old platform have no seamless way to get the new one and take advantage of bug fixes?

    It's easy to see you've never been in product development. It was hard enough for me 30 years ago with 20,000 installations and at least 3 different versions in use simultaneously. Then I got to work on another product with 500,000 installations consisting of version since 1.0, all of which had to keep running with the new version. Imagine Sun's and then Oracle's problem with tens, maybe hundreds, of millions of sites and support for at least 20 versions going back to 1.0.2.
  • 14. Re: Differences between JSF managed bean and back bean
    gimbal2 Guru
    Currently Being Moderated
    EJP wrote:
    Imagine Sun's and then Oracle's problem with tens, maybe hundreds, of millions of sites and support for at least 20 versions going back to 1.0.2.
    Yeah things are 'easy' when all you know is small-medium website scoped projects. Playing with the multimillion dollar big boys tends to open the eyes a bit more :)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points