Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Basic Struts work flow question

Reply
Thread Tools

Basic Struts work flow question

 
 
Ming
Guest
Posts: n/a
 
      11-15-2007
Hi there,

I am new to Struts. I am developing a small app to learn Struts. Could
you please give me some suggestions? Many thanks!

Scenario:

A very small web app. I have 3 tables: student, course, and student-
course. Student and course are 1:N relationship. student-course is a
bridge table, which takes user_id (from Student) and course_id (from
Course) as FKs. Anonymous users can view, registered users can edit,
admin can add,delete and edit. That's it!

As I am brand new to Struts, I do not want to use Hibernate or another
framework. I just want basic JDBC for db work.

My ideas:

1. For each action group (instead of individual action), create an
Action class. For example, UserAction (add,edit,delete users) instead
of UserAddAction, UserDeleteAction, UserEditAction. Is this a good
practice or not? Or shall I create an Action class for each individual
action (will that bring a lot repetitive codes?)

2. Like 1, for each action group, create an ActionForm class, like
UserActionForm

3. Create a JSP page for each individual action (not group) as the
input/entry page. For example, addstudent.jsp, deletestudent.jsp,
editstudent,jsp. Each JSP page use corresponding ActionForm bean. For
example, the above three JSP pages all use UserActionForm. However,
different JSP pages use different element of the ActionForm bean. For
example, user_id is not used in addstudent.jsp but is used in
deletestudent.jsp, as an id is required to delete a record but not
required to add one (I set id, the PK for Student table as auto-
increasement)

4. Create a db connection by using Singleton pattern

5. For each Action class, depending on different inputs, prepare sql
statement and pass the statement to the db connection created in 4.
Get a RecordSet as returned value

6. Create 3 javabeans to map three db tables

7. Construct javabean objects based on the RecordSet returned from 5.
For example, 比如select * from
Student will construct a Set<Student>

8. Use a loop in JSP page to get properties from the bean

That's my basic view on Struts. I have no idea if my view is okay or
bad. Could you please give me some help?

Additionally, I am not sure how to close the db connection,.as I need
to call the db many times. Within the Singleton patten db connection
class, as I need to return the RecordSet, how shall I close the db?
What shall be the order/sequence to do that?

Thanks a lot.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query:difference between node flow and filter flow in java's I/O,system? Jack Dowson Java 0 05-07-2007 03:35 PM
Basic Net Flow Configuration udo Cisco 3 05-07-2006 05:43 PM
Why Struts Flow Overview is empty in MyEclipse? jacksu Java 1 11-30-2004 01:57 AM
Struts Action Flow Dom Java 0 07-23-2004 10:59 AM
I need a very basic flow chart program Watcher@the.gate Computer Support 3 07-30-2003 01:42 AM



Advertisments