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 SessionValueModule extends BaseModule {
16: public void loadSessionVariable(WebPageRequest inContext)
17: throws Exception {
18: PageAction inAction = inContext.getCurrentAction();
19: String key = inAction.getConfig().getAttribute("bean");
20: Object bean = inContext.getSessionValue(key);
21: if (bean != null) {
22: return;
23: }
24: String className = inAction.getConfig().getAttribute("class");
25: if (className != null) {
26: SessionTool classTool = (SessionTool) inContext
27: .getPageValue(PageRequestKeys.CLASSTOOL);
28: if (classTool == null) {
29: classTool = new SessionTool(inContext,
30: getModuleManager());
31: inContext.putSessionValue(PageRequestKeys.CLASSTOOL,
32: classTool);
33: }
34:
35: inContext.putPageValue(key, classTool.construct(key,
36: className));
37: return;
38: } else {
39: bean = getBeanFactory().getBean(key);
40: if (bean != null) {
41: inContext.putSessionValue(key, bean);
42: return;
43: }
44: }
45: throw new OpenEditException("No such bean " + key);
46: }
47: }
|