KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dinamica > security > MenuOutput


1 package dinamica.security;
2
3 import dinamica.*;
4
5 /**
6  * Class description.
7  * <br><br>
8  * (c) 2004 Martin Cordova<br>
9  * This code is released under the LGPL license<br>
10  * Dinamica Framework - http://www.martincordova.com
11  * @author Martin Cordova (dinamica@martincordova.com)
12  * */

13 public class MenuOutput extends GenericOutput
14 {
15
16     /* (non-Javadoc)
17      * @see dinamica.GenericOutput#print(dinamica.TemplateEngine, dinamica.GenericTransaction)
18      */

19     public void print(TemplateEngine te, GenericTransaction data)
20         throws Throwable JavaDoc
21     {
22         
23         //reuse superclass code
24
super.print(te, data);
25         
26         //retrieve main recordset (menu titles)
27
Recordset menu = data.getRecordset("menu");
28
29         //load repeatable subtemplate
30
String JavaDoc section = getResource("section.txt");
31         
32         //buffer
33
StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
34         
35         while (menu.next())
36         {
37
38             //getmenu items
39
GetMenu m = (GetMenu)data;
40             Recordset items = m.getMenuItems(menu);
41
42             //build subpage
43
TemplateEngine t = new TemplateEngine(getContext(),getRequest(), section);
44             t.replace(menu,"");
45             t.replace(items,"","rows");
46             
47             //append subpage section
48
buf.append(t.toString());
49             
50         }
51         
52         //replace into main template
53
te.replace("${menu}", buf.toString());
54         
55     }
56
57 }
58
Popular Tags