• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using inheritance for managed beans

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
Is it considered bad or good practise to have managed beans inheriting from each other?

For example, I have a lot of similar backing beans.
I would like to factor out the commonality into a base backing bean.
I see no reason why I shouldn't do this,

Any tips or comments?

Thanks.
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a "BaseBean" that all my managed beans inherit from. The BaseBean itself is of course not a managed bean since I do not need it as one. And I have observed no problems whatsoever with this structure

EDIT: Now that I think about it I am no longer sure if I have a managed bean annotation in my base bean. At least I have managedPropertys inside it. I will check tomorrow. BTW I use JSF 2
 
Saloon Keeper
Posts: 28125
198
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
I have several apps that employ inheritance, both on managed beans and on domain model beans. No real problem as long as I mark the base bean to indicate any managed properties it may have.

The worst of my offenses are being committed in JSF2, but I'm pretty sure JSF1 supported inheritance too. I may even have some and just forgot about them.
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, no @ManagedBean annotation in my "BaseBean" as I thought.
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic