• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can I use Entity class as my managed bean?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the input fields of the (JSF) form are bound to a managed bean then the user state is automatically synchronized with the bean properties.

Can I use an Entity class as a managed bean? (If this is possible, I don't need to create a separate managed bean & simply persist the Entity instance with the data entered by the user to the database using JPA)
 
Saloon Keeper
Posts: 22267
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, technically you can, but it's not very flexible. Scan back through this forum over about the last 2 weeks and you'll see that the question has been asked (and answered) before.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the links of the relevant threads.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply?!
 
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can I use an Entity class as a managed bean?


Yes, sure. But this would be a bad practice since you shouldn't fill your ejbs with front-end garbage. And if you don't, the desing pattern will force you to fill you RAM with ejbs saved in session which leads to out-of-mem errors and server crashes. My recommendation would be to leave ejbs as they are and create controller managed bean filled with action methods where you would only instantiate ejbs. If you have trouble accesing Facade methods there just use @EJB annotation when declaring facade objects (ie @EJB MyClassFacadeLocal myClassFL;).
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean by Entity class in not regarding EJB but regarding JPA.
 
Tim Holloway
Saloon Keeper
Posts: 22267
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA is defined as part of the EJB3 specification. The same caveats apply whether you using simple JPA or full EJB.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA (JSR 317) is NOT part of EJB (JSR 318) specification starting from JavaEE 6, look at here:

http://java.sun.com/javaee/technologies/index.jsp
 
Tim Holloway
Saloon Keeper
Posts: 22267
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Namitha karupaiya wrote:JPA (JSR 317) is NOT part of EJB (JSR 318) specification starting from JavaEE 6, look at here:

http://java.sun.com/javaee/technologies/index.jsp



The operative words are "starting from". On page 441, note the following:


Created document from EJB 3.0 Java Persistence API Final Release draft.



There are no significant differences between JSR-317 and the earlier specs that invalidate the caveats.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it is EJB 3.1 not 3.0
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply?!
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Namitha karupaiya wrote:No reply?!



Why should we? So you can argue more? That will get you no where around here. Have you searched this forum as suggested by Tim? If not, please do so. As he said, this question has been answered multiple times before. And even so, the short answer is you can do it, but it is bad practice and and anti-pattern. So simply, don't do it.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg Bolinger,

I searched but could not find. PLEASE post the links of the relevant thread(s), if you are able to find them. (Please treat this as discussion, not argument!)

Thanks.
 
Tim Holloway
Saloon Keeper
Posts: 22267
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid our search engine is no Google[TM].

Most of what I've got here, I found by just paging back over postings for the last month or 2 and looking at likely topic names. I think there may be some others that go into more detail, but they're not immediately recognizable.

https://coderanch.com/t/212506/JSF/java/MVC-Model-Domain-Model#1015480

https://coderanch.com/t/473818/JSF/java/granularity-JSF-beans#2123780

https://coderanch.com/t/469486/JSF/java/JSF-EJB-target-unreachable-returned#2100676

https://coderanch.com/t/432929/JSF/java/Represent-Inheritance-Domain-model-JSF#1923469
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply?!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic