• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF JSP page and DB

 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm beginner in web application using Eclipse, I'm crating JSF JSP web application and I want to add new record to the DB. I have different layers or classes ( JSF's and managed bean to collect values from the UI, Business or controller class to get the inputs from managed bean class and interact with DAO class, the last one is DAO class to access the DB). So i have method in managed bean class that take values from the Inputs Textes from the user this method call it SaveT. Inside SaveT, this method will get values and pass them to another method in the Business class call it SaveTask that will receive the value and will pass them tho the AddTask that is on the DAO class. After that, the record will be add. I hope you understand me. can any one please, check if what I'm doing is right or no?

These are my classes with the jsf jsp page:


JSP page:





AddTaskBean class:






Business class:





TaskDAO class:





Thank you in advance.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Wadha!

We prefer that people keep example code short because once it no longer fits on a single screen, it's hard to get anyone who isn't being paid to help to take time to read it.

I did notice a few things that you need to look at, though.

1. Taglibs are obsolete in JSF version 2. So are JSP pages. This has been so for many years now. You need to look at xhtml View Templates and you need to upgrade your project to JSF 2 if it's a JSF 1.1 project.

2. You need to study the standards for JavaBean naming and capitalization.

3. It's not considered to be good practice to obtain a database connection directly in a web application. J2EE supports Database Connection Pools, which are much more efficient when handling large numbers of users.
 
wadha alketbi
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim Holloway, actually I have this task and I implement the DAO class with some methods to retrieve data from the DB and it's work with me. Now the new task is to crate a UI and dealing with it. so I will put short short:

JSP:





Method in ManagedBean class:





method in Business class:



method in DAO class:




now when I click on the save button that in my GUI, nothing happened

Thank you again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!