Re: Iterative Model
"Kirk Daries" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hmmm... Will talk to Suroor about this. Once he's done with his part, I'll re-evaluate the solution and try to come up with a flexible design we can implement. Either a concrete Model, or maybe a component. Will see what works best. --KD >>> [email protected] 2003/12/19 15:45:26 >>> Great! Any chance your new found solution can be made into a general purpose solution that anyone can use for dealing with nested structures of arbitrary depth? The solution + an example would be a great contribution to Barracuda! Jake At 10:28 AM 12/19/2003 +0200, you wrote: >Thanks for all the help guys. >Finally, got a solution that works. >Diez, your suggestion about "flattening the tree" was the key to success. >Thanks >Suroor. > > >>> [email protected] 12/18/2003 12:06:52 PM >>> >Hi guys. > >Havent worked on this for quite some time now. > >Diez, I get what you're saying below, but it still doesnt solve my problem. >These grids get loaded into memory at application startup and if you look >at the following XML examples, you'll notice that there can be any >variation as far as depth is concerned. >So, when processing these objects, the question of depth cannot be >answered except at runtime. >How do I go about processing this? > >Example 1: > <GridRows> > <GridRow ID="RowOne" Label="Row One"/> > <GridRow ID="RowTwo" Label="Row Two"/> > <GridRow ID="RowThree" Label="Row Three"/> > <GridRow ID="RowFour" Label="Row Four"/> > </GridRows> >Example 2: > <GridRows> > <GridRow ID="RowOne" Label="Row One"> > <GridRow ID="RowOneOne" Label="Row 1.1"/> > <GridRow ID="RowOneTwo" Label="Row 1.2"/> > </GridRow> > <GridRow ID="RowTwo" Label="Row Two"/> > <GridRow ID="RowThree" Label="Row Three"> > <GridRow ID="RowThreeOne" Label="Row 3.1"/> > <GridRow ID="RowThreeTwo" Label="Row 3.2"> > <GridRow ID="RowThreeTwoOne" Label="Row 3.2.1"/> > <GridRow ID="RowThreeTwoTwo" Label="Row 3.2.2"/> > </GridRow> > <GridRow ID="RowThreeThree" Label="Row 3.3"/> > </GridRow> > <GridRow ID="RowFour" Label="Row Four"/> > </GridRows> > > > >>> [email protected] 12/9/2003 3:26:03 PM >>> >Hi Suroor, > >this is something from the list a while ago. Does this give you an idea? >Basically, the recursion of your example is replaced by > >- setting the child collection to the child model when a new top-level object >is visited in iterate-next >- instead of diving into it recursively, the markup directives are beeing >called on the child model and then the childs are traversed. > >Of course this stuff can be nested as deep as you want - but unfortunately >only with pre-known depth. > >Jacob mentions two things: > >1) A FAQ entry about this. I'd be willing to contribute if we had setup a >wiki >or something alike - it seems to me that this is the way to go these days. > >2) automatic parent-child-models. Well - this _could_ be done, but only if >the >tree objects implement a certain Node-style interface - which is often not >desirable. > >Hope this helps, > >Diez > >---------- Weitergeleitete Nachricht ---------- > >Subject: Re: [Barracuda] Iterative Model >Date: Samstag, 15. März 2003 18:07 >From: Jacob Kjome <[email protected]> >To: [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 _______________________________________________ Barracuda mailing list [email protected] http://barracudamvc.org/lists/listinfo/barracuda --------------------------------------------------------------- ÂAll views or opinions expressed in this electronic message and its attachments are the view of the sender and do not necessarily reflect the views and opinions of the Provincial Government Western Cape (Âthe PGWCÂ). No employee of the WCPG is entitled to conclude a binding contract on behalf of the PGWC unless he/she is an Accounting Officer of the PGWC, or his or her authorised representative. The information contained in this message and its attachments may be confidential or privileged and is for the use of the named recipient only, except where the sender specifically states otherwise. If you are not the intended recipient you may not copy or deliver this message to anyone.Â