I am planning to use the Nesting Extension in my application and would like
to field comments on how to best implement a database persistance mechanism
in this framework.


The MonkeyStruts example uses one ActionForm bean on the outermost level
that links to other beans recursively in a parent child heirarchy.  It looks
like each child bean in the hierarchy is instantiated from methods called by
it's parents class.

I suggest the following for persistance:

ParentBean -> getAllBeansData() (in child bean class) -> getAllBeansData()
in JDBC class -> Parent instantiates new Child bean with the data returned

This way the parent beans control the population of the data in the children
beans as in the example, it just that instead of static data being used it
will come from the database.  I think this is correct.  Putting the logic to
populate the bean contents in the Action class would take control away from
the parent which seems to be methodology within the Nesting Extension.

When submitting a form I don't want to have to persist the whole tree to the
database each time so I propose adding a property to each bean that will
indicate if the contents are new or changed (dirty).  I think I should also
set a property in the outermost bean that indicates if an update, delete or
insert is being performed so that I don't have to look for the dirty bean if
none are dirty.  The plan is to then search recursively from parent to child
starting with the outermost bean for the dirty attribute in a bean.  If a
bean is dirty I will call a method in a JDBC class associated with the dirty
bean to perform the CRUD action.

To summarize I propose:

1.  Populating the form contents with methods contained in JDBC beans called
from the beans themselves. Actually called from a beans parent indirectly.
(Bean parent calls methods in child bean which calls a JDBC bean to get data
for a group of beans that the parent wants to instantiate and then the
parent bean instantiates the beans with the data grabbed from the database)

2.  Executing CRUD operations based on beans being marked "dirty" with
methods in JDBC classes from the Action Class assoiated with the form.



Is there a better way of doing this or am I on the right track?


-john




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

Reply via email to