a web-application that takes data from a jsp web-page form, and file that data to the database. I also want to be use jsp web-page forms to retrieve data from the database, maybe update that data and maybe delete data .... hence a web CRUD application.
I don't have any problems writing Connections to the database and executing PrepareStatements to create, retrieve, update, and delete ... that's not a problem ... but within Struts ... this data transfer to/from the database looks like it takes place with the "helper" bean (DTO bean maybe).
So ... it looks like I will ALWAYS need the "form bean" for the form data, and the Action/Servlet ... but what got me was that the form bean and the DTO look sooooo similiar, but Erik Weber explained that the "form bean" was going to have all strings from the jsp form, and the DTO bean will have the real int's, Strings, booleans, etc.
Anyway, thanks for the help.
Tom
Michael McGrady wrote:
Tom Holmes Jr. wrote:
I'm still a Struts newbie, but I have some confusion on the amount of classes I need to use in order to create a CRUD application.
I said you should not worry about struts when doing this and I will expand below:
From what I can see I need a "form bean" in order to capture the data from the JSP page.
Nothing to do with the CRUD applicaiton. Your CRUD application could not care if the data came from the Moon.
This contains the validate method which would verify some of the data from the JSP page. I also need an "Action" class/servlet that captures the action ...
Again, nothing to do with CRUD. Who or what uses the methods in CRUD is not a concern of CRUD.
so if I had Add, Update, or Delete button, the Acttion class/servlet would handle the action.
You don't need this coupling. Anything done, mentioned, intimated, in the Action should be separate from the CRUD. See http://www.acronymfinder.com/af-query.asp?p=dict&String=exact&Acronym=CRUD for a little humor.
Now, there is also the "bean" itself sometimes which has a 'DTO' in the name. I guess this is for "Data Transfer Object" which handles the create, retrieve, update, and delete database actions.
Connecting CRUD semantics like this to Action semantics is really dangerous, I think. It is not inherently wrong but it will lead someone astray sooner or later.
So, I'm a little unsure about the whole sequence of actions within struts, but here is what I want to do when I add a record.
When you add a record, you should just add a record. Period!
1) calls the action class/servlet execute method
2) calls the formbean class so it can validate if the data is ok
3) if there are errors return to the page configured in struts
4) if there are NO errors
a) then instantiate the DTO class (so we can update the database)
b) Instantiate the form itself which contains data we got from the JSP page
c) pass in the "formbean" into the DTO class, so we can transer the data to the DTO from the "formbean"
d) call the insert method within the DTO class to file the data to the database
e) if there is an error, then we should return false to the action class so we can take the action as defined in the struts-config.xml file.
If this is correct, or sort of correct, please let me know so I can adjust my thought process. Thanks for any information you can provide.
Just create the CRUD application on its own. Then worry about these things. Do not worry about Struts. Make a greate interface for users of the CRUD application, create the CRUD application. Then worry about these other things. That's my suggestion.
Michael
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]