> -----Original Message-----
> From: Tom Holmes Jr. [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 07, 2004 4:04 PM
> To: Struts Users Mailing List
> Subject: Confusion in Classes
> 
> 
> 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.
> 
>  From what I can see I need a "form bean" in order to capture 
> the data 
> from the JSP page.  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 ... so if I had Add, 
> Update, or 
> Delete button, the Acttion class/servlet would handle the action.
> 
> 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.
> 
> 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.

0) Instaniate the form bean, if not already existing.
0.1) transfer request params to form bean
0.2) validate form bean by calling validate
0.3) If errors, return to page indicated by input in the action mapping, otherwise 
keep trucking.

> 1) calls the action class/servlet execute method
XXXXXXXXXXXXXX> 2) calls the formbean class so it can validate if the data is ok
XXXXXXXXXXXXXX> 3) if there are errors return to the page configured in struts
XXXXXXXXXXXXXX> 4) if there are NO errors

>     a) then instantiate the DTO class (so we can update the database)

3) Copy relevant fields from form to VO/DTO performing parsing as needed.

XXXXXXXXXXXXX>     b) Instantiate the form itself which contains data we got 
XXXXXXXXXXXXX> from the 
XXXXXXXXXXXXX>   JSP page
XXXXXXXXXXXXX>     c) pass in the "formbean" into the DTO class, so we can 
XXXXXXXXXXXXX> transer the 
XXXXXXXXXXXXX> data to the DTO from the "formbean"
>     d) call the insert method within the DTO class to file 
> the data to 
> the database

DAO instead of DTO maybe?

>     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.

No.  Return the appropriate forward, usually failure, but could be more specific so 
struts can find the url to head to.  You could also just throw the exception on out, 
and handle it with the struts exceptionhandler.

> 
> 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.

Your welcome... helps to run things in debugger and trace things through.

> 
> Thanks.
> 
>                          Tom
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to