struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mansou...@yahoo.com
Subject MVC 2 design, how to
Date Thu, 05 Apr 2007 23:34:53 GMT
Hello every one:
I am trying to write a little application to familiarize myself with 
struts 2. I am trying to design the application using mvc2. the 
application is nothing but a small utility for invoices. It store, 
retrieves and update invoices. Each invoice belongs to an Account in the 
DB. from the examples I have seen so far, the Action class is populated 
by values from the jsp page.
So here's my design:

newAccount.jsp
                            <------> AccountManager.java (ActionSupport) 
<----> Account.java
veiwAccount.jsp            

Account.java is the class where all the bussiness logic goes. 
AccountManager is part of the controller and based on the results it 
gets from the Account.java it forwards to the appropriate view. The user 
can view an existing account or create one through the jsp pages. Now 
because it doesn't make scense to populate the AccountManager with 
getters/setters for the same fields in Account, I will pass Account as 
an attribute of the request to the view. I mean, if Account.java has 
fields , accountID, accountName , ... then I need getters and setters to 
access them, but the same getters and setters has to exist in 
AccountManager.java so that AccountManager can communicate with the 
views. However, I have read some where that because the bussiness logic 
may contain other resources ( ie, db connection, ..) we  don't pass it 
to the view, but we pass a minimal verion of that class as a bean. So, I 
'll create another class called ActionBean.java and populate it from 
within Account.java .

PLease note that AccountManager can be accessed from many places and 
depending on the output it forwards to the correct view.

I need an advice or comments, as I am new to struts 2 and MVC, and I 
feel that I am missing something.
Can any one please correct me or give me comments?

 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message