1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.components;
23
24 import org.apache.struts2.views.annotations.StrutsTagAttribute;
25
26 import com.opensymphony.xwork2.util.ValueStack;
27
28 /***
29 * Base class for control and data tags
30 */
31 public abstract class ContextBean extends Component {
32 protected String var;
33
34 public ContextBean(ValueStack stack) {
35 super(stack);
36 }
37
38 protected void putInContext(Object value) {
39 if (var != null && var.length() > 0) {
40 stack.getContext().put(var, value);
41 }
42 }
43
44 @StrutsTagAttribute(description="Name used to reference the value pushed into the Value Stack")
45 public void setVar(String var) {
46 if (var != null) {
47 this.var = findString(var);
48 }
49 }
50
51 /***
52 * To keep backward compatibility
53 * TODO remove after 2.1
54 */
55 @StrutsTagAttribute(description="Deprecated. Use 'var' instead")
56 public void setId(String id) {
57 setVar(id);
58 }
59
60 protected String getVar() {
61 return this.var;
62 }
63 }