Re: How to get more detail on a list selection

Vic Cekvenich <[email protected]> Fri, 16 May 2003 09:27:41 -0400
Newsgroups gmane.comp.java.mvc.devel
Organization baseBeans Engineering
Message-ID <[email protected]>

Rick Reumann wrote:

>How would you accomplish the following...
>
>
>I have a ProjectBean(BaseBean) which is used to hold the 'typical' project
>information that I like to display in a table (ie Title, Description,
>Status, Priority, Date Requested, Contact, etc.). Everything is fine with
>the above.
>
>I then want to be able to click on the project name and brought to a
>"details" page that not only displays the above information but then also
>will display a list of "notes" - notes are just entered in note entries
>into a separate table. Also I could forsee displaying other detail
>information from another table such as status change history.
>
>What is the best way to handle the above? Assuming I already have a
>NoteBean, do I need to build another bean ProjectDetailBean that in Ibatis
>will map to NoteBean to populate the NoteBean into ProjectDetailBean?
>

The Assuming part is key, you must have 2 working beans. In modular 
development, such as MVC, you must have tested compoents; that you then 
assemble tested working components.
If you have note read this:
http://keyboardmonkey.com/next/index.jsp
Please study and understand concept.... before you read this next part, 
so you will find it KISS, else you will get confused and spend more time 
getting unconfused.

Look in package org.apache.basicPortal.newsBlg;
import org.apache.basicPortal.coreBeans.*;
public class *NewsBlgCmntFBean* extends CmntsBean {
protected ContentBean _contentBean = null;
// this is an compound (nested) bean assembled for the form
public ContentBean getContent() { return _contentBean; }

See how I use 2 tested beans, in a "is a/has a" OO?
So NewsBlgCmntFBean is a CmntsBean and had a ContentBean! I assembled 2 
working beans, master/detail style.

Or KISS version: getBean() for componund/comex forms!

Now instead of Nested tag I use JSTL "bean.property" syntax. I can nest 
many (tested) beans for complex relationships, and nest to multiple levels.

On Crud, save needs transactions so that all the bean1.save(); and 
bean2.save(); commit.
Most real forms are compound/complex, and most have multiple nestings. 
The "simple" beans is just to teach modular development, but not much 
use in "real" development, other than for assembly.

If you are writing project managment, like JIRO, you should have tasks 
(and one of the tasks fields is a note). A very basic master/detail.

I think you can see that manay to many is just as easy and... even more 
complex is no problem (assuming developers have discipline to test each 
"simple" bean).

.V




>Really all I need is the one Row from the ProjectBean and then a query to
>NoteBean based on projectId, but is there really doesn't seem to be a
>place for this type of behvior to take place in the BaseBeans approach. I
>suppose I could modify one of the actions to create a NoteBean instance
>and then call populate(long id) and then put the NoteBean in scope.... but
>you seem to be against that. Maybe just creating another bean
>ProjectDetailBean is the best way to go?
>
>If I do create a ProejectDetailBean, I'm having a difficult time with
>Ibatis trying to figure out how to have it populate ProjectDetailBean. In
>other words ProejctDetailBean really only needs :
>
>ProjectBean projBean;
>NoteBean noteBean;
>
>//get and sets to get and set HashMap with the above beans
>
>But then the question is how do I populate this in Ibatis?
>
>It looks like I'd want to do something like...
>
><result-map name="resultDetail" class="projectUtility.ProjectBean">
>
><property name="noteBean" column="projectId"
>mapped-statement="NoteSelectAll"/>
>
><property name="projectBean" column="projectId"
>mapped-statement="ProjectSelectOne"/>
>
></result-map>
>
>
>but then I also need a mapped statement to call:
>
><mapped-statement   name="ProjectDetail"  result-map="resultDetail"
>cache-model="project_cache" inline-parameters="true">
>        //really I don't need anything called here - because I just
>	//want "resultDetail" to get called, but it looks like you
>	//need some statement here?
></mapped-statement>
>
>
>Basically I'd like to call the mapping "ProjectDetail" which in turn would
>call NoteSelectAll and ProjectSelectOne, but I can't get this to work.
>
>
>How do you handle this under a BaseBeans framework?
>
>Thanks,
>
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East. 
Open Source <a href ="baseBeans.com">Content Management</a>  basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress