Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
MVC implementation question using Swing

MVC implementation question using Swing

2004-05-19       - By Martin C?

 Back
Reply:     1     2  

Hi,

A question on how to implement the MVC design pattern.

I'm currently building a personal application using
Java with Swing.  I would eventually like to port it
on JSP/Servlet as well.

I always imagined as the Model being completely
separated from the Controller and the View.  The model
classes shouldn't know about the View or the
Controller.  However, I see the model classes should
extend the Observable class and enable the other 2 to
be notified on data changes.

Now, if I have a main class that is used to execute
the program, I would see the implementation of the MVC
in that class as:

Model rootModel = new Model();

Controller rootController = new Controller(rootModel);
String language = "en";
View rootView = new View(rootController, rootModel,
language);

(Please, correct it if that's incorrect.)

My problem comes from the fact that the main 'root'
model class is taking arguments that is obtained from
one of the UI.  More specifically, my 'root' model
class is User, which logically should always take a
firstname and lastname.  To me, it doesn't really make
sense to have a user with a blank firstname/lastname.
However, to get this information, I need to display
the login window.

Should I create a 'higher' root model class that
wouldn't take any parameters and create the User
object only once I got the information?  Something
similar to the "session" when you're coding using JSP
and servlet; like "MyAppSession"?

Or should I break all these 'groups' into multiple
classes visible by the main class?  I'm kind of
reluctant to do that.  That would mean that there
would be multiple instanciation of view classes in the
main class, etc.

Or is there any options I'm leaving out?  Am I taking
the right approach towards the MVC design pattern?  Or
if you could suggest a different approach to implement
the whole thing...

Thanks for your help,
Martin




__ ____ ____ ____ ____ ____ ______
Do you Yahoo!?
Yahoo! Domains ? Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.