• Post Reply Bookmark Topic Watch Topic
  • New Topic

i can't persist object using jsf managedBean  RSS feed

 
simo sevmeek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a web application using spring and JSF framework. In that i using entity class. In ManagedBean class i want to insert the data using entitymanager (JPA) persist method. But it will not working. And don't show any errors. give me the suitable methode to insert data into the database using EntityManager.Persist() method.
Thank you
 
K. Tsang
Bartender
Posts: 3632
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Have a look at here, and here

Hope they will give you an idea.
 
simo sevmeek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you K. Tsang , I want to inform you that I used Spring instead of EJB
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Simo!

JSF has no built-in database functionality. Whatever code you would implement for a non-JSF webapp would be essentially the same database logic that you'd use in a JSF web application.

When working with Spring, there's a an EL bridge module that you can include in your faces-config.xml file. That module allows Spring beans to be referenced in EL just like JSF Managed Beans are, which means that you can inject a Spring DAO or persistence services bean into a JSF backing bean.

I do NOT recommend that you actually inject EntityManagers into JSF managed beans. Use a DAO or persistence service the way you would using a Session EJB if you were using EJB. By isolating the GUI functionality of the JSF backing beans from the persistence functions of JPA you'll have code that's easier to understand and maintain.

Spring has extensive logging capabilities so if you're having problems seeing errors, adjust the logging levels for your web application. And whatever you do, DON'T do stuff like this:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!