Last time I sugested M. V. C. and you did not like, as I said maybe you over design?
Try again: When looking at the problem, try allways to use a simple design.
Suggestion:
Start with listing you forms (pages)!
projectDetail.jsp
Each form has a an action, we call action to get to the jsp.
ProjectDetailAct
So just program navigation for now, a menu gets to this. Call action to return a jsp. No thinking in MVC.
Maybe you have projectList, and other pages.
Anyway, just get the navigation right and working first, ignore the beans.
If you are happy with how navigation works (but it does not display date) you are done with your prototype (in iterative development). Nvigation and presentation have nothing to do with form beans.
Take a beak now.
Then you need formBeans. FormBean matches the form (jsp. Again no thinking).
Some forrms are nested. Ex: A project jsp has project info and a list of tasks, so 2 form beans.
You MUST unit test all the form beans individualy and nested OUTSIDE of Struts. (So write DAO, SQL and unit test; unit testing saves time).
So you write a test servlets (and implement required test method in the bean) that does ProejctDetailBean.populate() and display some data.
Of course calling ProjectDetailBean poppulate ends up calling taskBean.populate(), so that nested bean has data.
If you unit test this and it works, step 2 done. Take a break.
Now assign the form bean in struts, and in action add bean.populate, and integrate the 2 tested layers. Step 3 done.
>From what I am reading, you are kind of trying to not write MVC every time or go step by step. Taking shortcuts is slower, so just go step by step, and write MVC, if you are trying to short cut I can't help you.
Else we realy need to talk voice if I do not guess where you are stuck. Slow down to speed up.
.V
Rick Reumann wrote:
On Fri, 30 May 2003 12:01:08 -0400, Rick Reumann wrote:I'm running into major headaches using the basicPortal approach with an app that has ProjectBeans, TaskBeans, and NoteBeans. The problem is that conflicts arise since a taskBean and projectBean both have a field called "title" and "description." It's complicated by the fact that I have a ProjectDetailBean which extends ProjectBean and has the fields in it TaskBean and NoteBean so that I can display on a page the Project with the list of tasks and notes. When I go from that page to "add a task" it ends up also changing the ProjectBean title and description to the same Task title and description. (It doesn't save it to the db, but changes the list in session scope).The problem once again falls back to the idea of having the forward of one Action foward to another Action. The problem is that say you have a bean in scope with a field "title" then after you submit your forward forwards to another action which sets up another bean - but that other bean being set up ALSO has a "title" field - which ends up being populated by other bean.To get around this problem I'm not having certain actions forward to other actions. For example I have a projectDetailAction which sets up a ProjectDetailBean (with Project, Tasks, and Notes) and forwards to a displayDetail page. Now when on that page if you click on "add task to this project" you are fowarded to the "taskAdminAction" and eventually after "Save" is submitted (saving the task) the idea I wanted was to then forward to the projectDetailAction. This creates problems as projectDetailAction has a ProjectDetailBean associated with it which ends up having it's title and description populated from the Task bean still in scope. The solution is that after I save the task I set up the ProjectDetailBean inside of the TaskAdminAction and forward directly to the display page. This breaks the concept of particular Actions being only responsible for their unique thing, but I'm at a loss of a better solution. The other solution that isn't 'that' bad is that when the TaskAction fowards over to the ProjectDetailAction I always make sure to create a completely new ProjectDetailBean inside the Action and call ae.setReqBean( theNewBean ) after populatin the bean of course. This solution seems to maybe be better?
-- Vic Cekvenich, Struts Instructor, 1-800-917-JAVA Advanced <a href ="">Struts Training</a> and project recovery in North East. Open Source <a href ="">Content Management</a> basicPortal sofware Best practice<a href ="">Struts Support</a> v.1.1 helper ScafflodingXPress