01: package simpleorm.simplewebapp.core;
02:
03: import simpleorm.simplewebapp.core.WException;
04:
05: /**
06: * Common supertype of FieldGroup and Field.
07: * Currently fields form a flat, two level structure (Groups and Fields) but that
08: * could be changed to a general hierarchy later.
09: * (The main restriction is JSP/EL's abilities.)
10: */
11: public abstract class WFieldNode {
12: String shortName; // immutable
13: WPagelet pagelet;
14:
15: void setPagelet(WPagelet pageletp, WPage page) {
16: if (pagelet != null)
17: throw new WException("FieldNode already added " + this
18: + pagelet);
19: pagelet = pageletp;
20: if (getPage() != page)
21: throw new WException("FieldNode not in Page " + getPage()
22: + page);
23:
24: }
25:
26: public WPagelet getPagelet() {
27: return pagelet;
28: }
29:
30: public WPage getPage() {
31: return pagelet.getPage();
32: }
33:
34: public String getName() {
35: return shortName;
36: }
37:
38: /** The name used in the HTML <INPUT name=... tag.
39: * Currently short name, may become full name later.
40: */
41: public String getHtmlName() {
42: return getName();
43: }
44:
45: /** The name to uses as a prompt, ie. translated HtmlName.
46: * NOT html escaped by caller. Should we escape here or allow exotic translations?
47: */
48: public String getPrompt() {
49: return pagelet.getPage().translate(getHtmlName());
50: }
51: }
|