01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.action;
19:
20: import de.finix.contelligent.CallData;
21: import de.finix.contelligent.ComponentPath;
22: import de.finix.contelligent.components.legacy.ComponentReference;
23: import de.finix.contelligent.util.ThreadedMem;
24:
25: public class MutableLink extends ComponentReference {
26:
27: private String storageScope;
28:
29: private String storageKey;
30:
31: public boolean isDynamic() {
32: return true;
33: }
34:
35: public void setStorageScope(String scope) {
36: storageScope = scope;
37: }
38:
39: public String getStorageScope() {
40: return storageScope;
41: }
42:
43: public void setStorageKey(String key) {
44: storageKey = key;
45: }
46:
47: public String getStorageKey() {
48: return storageKey;
49: }
50:
51: public boolean scopeSession() {
52: return storageScope.equals(Constants.SCOPE_SESSION_STRING);
53: }
54:
55: public boolean scopeRequest() {
56: return storageScope.equals(Constants.SCOPE_REQUEST_STRING);
57: }
58:
59: protected String getSessionStorageKey() {
60: if (storageKey != null) {
61: return storageKey;
62: }
63: return ctx.getPath().toString();
64: }
65:
66: protected String getRequestStorageKey() {
67: if (storageKey != null) {
68: return storageKey;
69: }
70: return ctx.getPath().getName();
71: }
72:
73: public ComponentPath getTargetPath() {
74: Object value = getObject(ThreadedMem.getCallData());
75: if (value == null)
76: return super .getTargetPath();
77: else
78: return new ComponentPath(value.toString());
79: }
80:
81: protected Object getObject(CallData callData) {
82: if (callData == null)
83: return null;
84: if (scopeSession()) {
85: return callData.getSessionAttribute(getSessionStorageKey());
86: } else {
87: return callData.getRequestAttribute(getRequestStorageKey());
88: }
89: }
90:
91: }
|