Re: Barracuda: 2 Iterations with 1 model
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Thuong, Sorry I don't have anything definitive to answer your question, but I'll take a stab at a couple suggestions... If you were iterating over a collection that contained collections of categories, you could have your main iteration iterate on the whole collection and then iterate over each collection of categories within that. In the directive for the subtotal row, just check if the current category has another element. If so, then return null (effectively hiding the element) and if not, then write out the stored total of that category. When that iteration gets done, just let the outer iterator move on to the next element and do it all again. The grand total could be calculated this way as well, or it could just be in a separate iteration, but you'd have to provide access to the collected subtotals somehow. I'd definitely look into the custom directives to see what might help you out there too. One other thing to think about is to use a BTable component or multiple BTable components. You can take advantage of using a table for each category and use <tfoot> elements to put the subtotals in the proper place. Everything else would be in <tbody> or <thead>. All subtotals would go in the <tfoot> of each table and the outer tables <tfoot> could contain the grand total. With that technique, there is no concern about order. You could figure out the subtotal first, even, place it in the <tfoot> and then do everything else. The order is irrelevant. If all else fails, you can always have full control over everything if you use XMLC directly. Of course, why would you want to do that when Barracuda is there to hide some of the gory details of XMLC? When you find the solution, can you post an explanation of it to the list? I'm sure it would be helpful. Once the new server is up and running, we can provide a repository for tips and tricks. Jake At 05:51 PM 12/5/2002 -0800, you wrote: >Hi, > >I wonder if someone has done something similar to what I'm trying to do >below (or have any ideas on how to do it). > >In the HTML below, I'm trying to render a table that includes a row for >every items (books) and, for each category of items, a "sub-total" row. >The very last row contains the grand total. I can have a model >implementing IterativeModel to iterate over each item. However, I >couldn't figure out how to render (handle) the "sub-total" row. There >could n number of items per category .. So I can't just have a >pre-determined number for <tr>'s. > >One option I can think of is to have 2 iterations, but still using only >one model. I'm not sure that would work ... But that's the idea of what >I'm trying to do. However, I would like to see if I can take advantages >of directives like Veto_If_Null (or other custom directives) ... And to >hide or display the correct rows. > >Hope you know what I'm talking about (or want). If not, I can explain >further. > >Thanks in advance! >-tn > > ><table> ><tr> > <td>Category</td><td>Title</td><td>Quantity</td><td>Price</td> ></tr> ><tr> > <td>Sports</td><td>MLB: The >History</td><td>1</td><td>$10.00</td> ></tr> ><tr> > <td>Sports</td><td>The 2003 Seattle >Mariners</td><td>2</td><td>$29.00</td> ></tr> ><!-- sub total row --> ><tr> > <td colspan=2>Sports total</td><td>3</td><td>$39.00</td> ></tr> ><tr> > <td>History</td><td>Planet Hong >Kong</td><td>1</td><td>$31.00</td> ></tr> ><!-- sub total row --> ><tr> > <td colspan=2>History total</td><td>1</td><td>$31.00</td> ></tr> ><!-- grand total row --> ><tr> > <td colspan=2>Grand total</td><td>4</td><td>$70.00</td> ></tr> ></table> > >_______________________________________________ >Barracuda mailing list >[email protected] >http://www.enhydra.org/mailman/listinfo.cgi/barracuda >FAQ - http://www.jguru.com/faq/Barracuda