This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes what could be the better way of saving data using jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "what could be the better way of saving data using jsf" Watch "what could be the better way of saving data using jsf" New topic

what could be the better way of saving data using jsf

Amee Dabo
Ranch Hand

Joined: Dec 22, 2001
Posts: 74

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?

Viswanath Sriram

Joined: Jul 20, 2006
Posts: 12
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 need not write the insert query to do this.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
Amee Dabo
Ranch Hand

Joined: Dec 22, 2001
Posts: 74
Thanks Viswanath & Merrill. Nice forum..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: what could be the better way of saving data using jsf
Similar Threads
JDialog return value
JSF... My post-JavaOne impressions.
Version problems with IE 5.0 and IE 6.0
How to use Shale with JSF
Capturing a list of details from the UI to ActionForm