01: /*
02: * Created on Dec 6, 2004
03: */
04: package com.openedit.modules;
05:
06: import com.openedit.OpenEditException;
07: import com.openedit.WebPageRequest;
08: import com.openedit.page.PageAction;
09: import com.openedit.page.PageRequestKeys;
10: import com.openedit.util.SessionTool;
11:
12: /**
13: * @author Matthew Avery, mavery@einnovation.com
14: */
15: public class PageValueModule extends BaseModule {
16: public void loadPageVariable(WebPageRequest inContext)
17: throws Exception {
18: PageAction inAction = inContext.getCurrentAction();
19: String key = inAction.getConfig().getAttribute("bean");
20:
21: String className = inAction.getConfig().getAttribute("class");
22: if (className != null) {
23: SessionTool classTool = getLoader(inContext);
24: inContext.putPageValue(key, classTool.construct(key,
25: className));
26: return;
27: } else {
28: Object bean = getBeanFactory().getBean(key);
29: if (bean != null) {
30: inContext.putPageValue(key, bean);
31: return;
32: }
33: }
34: throw new OpenEditException("No such bean " + key);
35: }
36:
37: public SessionTool getLoader(WebPageRequest inContext) {
38: SessionTool classTool = (SessionTool) inContext
39: .getPageValue(PageRequestKeys.CLASSTOOL);
40: if (classTool == null) {
41: classTool = new SessionTool(inContext, getModuleManager());
42: inContext.putSessionValue(PageRequestKeys.CLASSTOOL,
43: classTool);
44: }
45: return classTool;
46: }
47: }
|