File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes  How to edit database table in jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark " How to edit database table in jsf" Watch " How to edit database table in jsf" New topic

How to edit database table in jsf

Adnan Gondal
Ranch Hand

Joined: Apr 30, 2011
Posts: 35
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:

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to edit database table in jsf
It's not a secret anymore!