The Model is something, conceptually, outside of Struts.  Struts provides
nothing for dealing with the Model.

Imagine that you write some classes that know how to talk to your
database, know how to perform your business logic.  Further imagine that
these classes have a known set of methods (i.e., expose a known interface)
that can be called to form the application.

More specifically, imagine you have an application where you want to be
able to maintain a list of students and what classes they are taking in
school.  Without arguing about how best to actually architect this (i.e.,
let's forget about DTOs and DAOs and persistence layers and all that and
keep it simple), you might come up with something like this:

Class Student
-------------
Method: List listStudents()
 lists all students in the database
Method: void createStudent(String studentName, String ssn)
 Creates a user with a given SSN in the database
Method: Map getStudent(String studentName)
 Gets all the details for a given student from the database
Method: void addClass(String studentName, String className)
 Adds a class a given student is attending
Method: void deleteClass(String studentName, String className)
 Deletes a class a givent student is attending
Method: List listClasses(String studentName)
 Lists all the classes a given student is attending

>From this you can create a webapp that allows you to list students, pick
one, see their details including what classes they are taking, and add and
remove classes.  Again, we're ignoring how you really should architect
this, I'm just trying to get the basic point across.

Also note that this is completely independant of the fact that you are
writing a webapp.  You can just as easily write a Swing-based client that
uses this class, or any other presentation technology.

Now, you have a single class that exposes a known interface that for all
intents and purposes represents your model.

Now, from your Struts Actions, you call these methods and render the
results as appropriate.  The method parameters like studentName and
className would probably be coming in as request parameters, so you just
instantiate your Student class and call the appropriate method, then take
the result and pass it to the view for display.  Struts itself doesn't
deal with the model for you.  How you get at these classes is also up to
you... could be a JNDI lookup, could be just included with your app, etc. 
Struts leaves this to you entirely.

Hope that answers your question :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Fri, July 29, 2005 9:40 am, Carl Smith said:
>
> Struts privide strong C (of MVC) components, tyical of which are
> ActionServlet, Actions  and RequestProcessors, but I am wondering which
> part is the M (of MVC).
>
> Thanks.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to