• 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

what could be the better way of saving data using jsf

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Using JSF I am working on a simple example which saves employee data into database.I have :
1. Created a employee jsp which will have 'Save' button
2. On click on 'Save' button a method Employee backing bean's saveEmployee() will get called.
3.Via this method have given a jdbc call which inserts employee data into database.

My doubts:
1.Is this the correct way am I following? or is there any other better way of saving data using JSF?
2.My manager asked me to use Shale architecture along with JSF. But I am not at all aware how to use this Shale architecture. I went through the website but could not figure out how it can be used.Any inputs please?
3.Can you provide me good links for learning Shale architecture?

Thanks..
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya we can do this using save() in hibernate.create the bean object and set the data to the bean then save the bean object using sace method.you need not write the insert query to do this.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's certainly nothing wrong with writing JDBC code for data access. My only suggestion would be to extract the JDBC code to another class using the Data Access Object (DAO) pattern. That way you make sure your model logic is more loosely coupled to your controller logic in the MVC architecture.
 
Amee Dabo
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Viswanath & Merrill. Nice forum..
 
Saloon Keeper
Posts: 27808
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
In most cases, you'd pick either JDBC or one of the ORM technologies (EJB, JDO, Hibernate) to manage persistent data. JDBC has the advantage of being something you can hack out in a hurry. ORM has the advantage of allowing you to talk to the database in Java form. It's more trouble to set up, but scales up better.

JDBC, interestingly enough, benchmarks slower than most current ORM platforms.

A DAO layer allows you the flexibility to swap in and out for the persistence mechanism that works best - including a mock layer for testing purposes. The downside is some added complexity.

Spring is a nice thing to pair with JSF for persistency purposes, BTW. It's fairly lightweight, but it makes the individual modules simpler and more reliable, and it handles a lot of the repetitive "grunt work" for you. Once again, added complexity in terms of number of program parts, but the individual parts become simpler. The tradeoff being development costs versus what the progam will cost in ongoing maintenance.
 
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic