Re: Iterative Model
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
As a follow-up to what Diez says, here is something Diez actually sent me
quite a while ago that I think might help...
ParentModel extends AbstractTemplateModel implements IterativeModel {
ParentItem current;
ParentItem getCurrent() {return current;}
/* ... all the model-stuff */
public void loadNext() {
current = calcMyNextCurrentItem();
}
}
ChildModel extends AbstractTemplateModel implements IterativeModel {
public ChildModel(ParentModel); // Save the ref to ParentModel
public void preIterate() {
ParentItem pi = parentModel.getCurrent();
childs = pi.getMyChildsAsList();
}
}
Hope that helps.
This really does need to be in a FAQ of some sort. Anyone want to start
work on that? It would also be nice to have a more automatic way for child
models to interact with parent models more automatically. I'm not saying I
have something in mind. It just seems this could be done in a more elegant
way.
Jake
At 01:39 PM 3/15/2003 +0100, you wrote:
>Hi,
>
> > I am trying to figure out how to use the current Iterative Model to do
> > this. Has anyone come across similar problem ? Any insight regarding this
> > would be really helpful.
>
>Search the mail archives for parent and child iteratice models. The basic
>idea
>is to have two models, where the outer one initializes the inner one when
>iterateNext is called - or the inner one queries the outter one about its
>parent object in the preIterate method.
>
>Diez
>_______________________________________________
>Barracuda mailing list
>[email protected]
>http://barracudamvc.org/lists/listinfo/barracuda