This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

what could be the better way of saving data using jsf

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Viswanath & Merrill. Nice forum..
 
Saloon Keeper
Posts: 21985
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
I was born with webbed fish toes. This tiny ad is my only friend:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic