01: package simpleorm.simplewebapp.eg.database;
02:
03: import simpleorm.simplewebapp.core.WTree;
04: import simpleorm.simplewebapp.eg.dbute.WUser;
05: import simpleorm.simplewebapp.dbute.WGenericCrudPagelet;
06: import simpleorm.simplewebapp.dbute.WGenericTree;
07:
08: public class WUserTreePage extends WTestPage {
09:
10: public final WUserTreeCrudlet pagelet = new WUserTreeCrudlet(this );
11: public final WUserTreePagelet treelet = new WUserTreePagelet(this );
12:
13: public WTree getTree() {
14: return treelet.tree;
15: }
16:
17: public static class WUserTreeCrudlet extends WGenericCrudPagelet {
18:
19: public WUserTreeCrudlet(WUserTreePage page) {
20: super (page, WUser.meta);
21: generateCrudFields();
22: }
23: }
24:
25: public static class WUserTreePagelet extends WTreePagelet {
26:
27: WTree tree = new WTree();
28:
29: public WUserTreePagelet(WUserTreePage page) {
30: super (page);
31: }
32:
33: @Override
34: protected void onPreMaybeSubmitted() throws Exception {
35:
36: String me = getPage().getPageContext().encodeContextUrl(
37: getPage().getPageItem().getUrl());
38:
39: WTree.WTreeNode t = tree.addNode(null, "Top", me);
40: WTree.WTreeNode u = tree.addNode(t, "Users", me);
41:
42: WTree.WTreeNode ur = tree.addNode(u, "By Role", me);
43: new WGenericTree().addSubTree(tree, ur, WUser.meta,
44: WUser.ROLE, WUser.NAME, WUser.USER_ID, me);
45:
46: WTree.WTreeNode ul = tree.addNode(u, "By Location", me);
47: new WGenericTree().addSubTree(tree, ul, WUser.meta,
48: WUser.LOCATION, WUser.NAME, WUser.USER_ID, me);
49:
50: addAnimals(t);
51: }
52:
53: void addAnimals(WTree.WTreeNode t) {
54: String me = getPage().getPageContext().encodeContextUrl(
55: getPage().getPageItem().getUrl());
56:
57: WTree.WTreeNode a = tree.addNode(t, "Animals", me);
58: tree.addNode(a, "Lion", me);
59: tree.addNode(a, "Tiger", me);
60: tree.addNode(a, "Dragon", me);
61: tree.addNode(a, "Walrus", me);
62: tree.addNode(a, "Elephant", me);
63: tree.addNode(a, "Mouse", me);
64: tree.addNode(a, "Worm", me);
65: tree.addNode(a, "Bug", me);
66: tree.addNode(a, "Bee", me);
67: tree.addNode(a, "Betle", me);
68: tree.addNode(a, "Buzzard", me);
69: }
70: }
71: }
|