01: package simpleorm.simplewebapp.core;
02:
03: import simpleorm.simplewebapp.core.WPage;
04: import simpleorm.simplewebapp.context.WPageContext;
05:
06: /** Created per Servlet to represent either an item or a (sub)menu<p>
07: *
08: * Menus can be created independently from WPages, used for despatching.<p>
09: *
10: * Menus are currently three levels -- url mapped as /context/servlet/parentMenu/MenuItem.swb.<p>
11: *
12: * WARNING. Menus are created per (global) servelet, must not have any per wpage instance information.
13: * The static WPageStructure.getThreadPage provides that.<p>
14: *
15: * Menus are not shared between servlets, so they do have a context and servlet name.<p>
16: *
17: * It is the WServlet that sets the page.menu and page.pageItem based on the URL used to
18: * find it.
19: * If the page is defined on multiple menus this may or may not be correct.
20: * But adding the same page to multiple menus is confusing to the user and so a generally bad idea.<p>
21: *
22: * WARNING These are generally Global (ie final values), see WGlobalState.
23: * Do not modify them on a per page basis, but do refer to them using
24: * WPageStructure.getPageItem etc. in case there are local coplies.<p>
25: */
26: public abstract class WMenuAbstractGlobal {
27: WMenuParentGlobal parent;
28: String name; // Simple name, eg. "WManualListPage". No .swb
29:
30: /** For items the real url, else the prefix for all the children. */
31: String swbUrl; // /servlet/menu/item.swb, Without context
32:
33: protected WMenuAbstractGlobal(WMenuParentGlobal parent) {
34: this .parent = parent;
35: this .name = getClass().getSimpleName();
36: }
37:
38: /** Hack to be removed. */
39: public String getAbsoluteUrl(WPage page) {
40: WPageContext ctx = page.getPageContext();
41: String url = ctx.encodeContextUrl(swbUrl); // todo make urls absolute
42: return url;
43: }
44:
45: /////////////////////////////
46: public String getName() {
47: return name;
48: }
49:
50: public <M extends WMenuAbstractGlobal> M setName(String name) {
51: this .name = name;
52: return (M) this ;
53: }
54:
55: public WMenuParentGlobal getParent() {
56: return parent;
57: }
58:
59: public String getUrl() {
60: return swbUrl;
61: }
62:
63: public void setUrl(String url) {
64: this.swbUrl = url;
65: }
66:
67: }
|