This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to edit database table in jsf

 
Adnan Gondal
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I'm having a bean class with id,firstName,lastName attributes having public getters and setters, and an updateEmployee method.

i'm using following jsf page to get database table values.

When i click on update button success page is shown but values are not changing in the database. Can any one tell me the reason that why vales are not getting change in the database?

Thanks in advance.

JSF page:

Employee.java:

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17620
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF does not include any persistency functions at all. It leaves that task for other frameworks, such as Hibernate.

To save a datatable after editing it, you need an action method that will be invoked when you click the "Submit" button on the form that displays the datatable. When that method is called, the dataModel that's backing the dataTable View will have been updated with the user's new values (after having first been validated). So at that point, it's up to you to provide logic to persist that dataModel out to the database.

When using an ORM such as hibernate/JPA, you can often use your Domain Model as the View Model, which can make the whole process fairly simple. Sometimes, however, the View model and domain models aren't quite identical, however, so in cases like that you'd have to build up and persist your own Domain Model.

If you're not using an ORM, and are, for example, using raw JDBC, you simply have to create code to iterate through the View Model and supply the appropriate JDBC insert/update functions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic