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

How to edit database table in jsf

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Saloon Keeper
Posts: 27862
196
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
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.
reply
    Bookmark Topic Watch Topic
  • New Topic