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.struts.faces.component;
23
24
25 import javax.faces.component.UIOutput;
26 import javax.faces.context.FacesContext;
27 import javax.faces.el.ValueBinding;
28
29
30 /**
31 * <p>Custom component that replaces the Struts
32 * <code><html:base></code> tag.</p>
33 */
34
35 public class BaseComponent extends UIOutput {
36
37
38
39
40
41 /**
42 * <p>Create a new {@link BaseComponent} with default properties.</p>
43 */
44 public BaseComponent() {
45
46 super();
47 setRendererType("org.apache.struts.faces.Base");
48
49 }
50
51
52
53
54
55 /**
56 * <p>Target frame.</p>
57 */
58 private String target = null;
59
60
61
62
63
64 /**
65 * <p>Return the component family to which this component belongs.</p>
66 */
67 public String getFamily() {
68
69 return "org.apache.struts.faces.Base";
70
71 }
72
73
74 /**
75 * <p>Return the target frame.</p>
76 */
77 public String getTarget() {
78
79 ValueBinding vb = getValueBinding("target");
80 if (vb != null) {
81 return (String) vb.getValue(getFacesContext());
82 } else {
83 return target;
84 }
85
86 }
87
88
89 /**
90 * <p>Set the target frame.</p>
91 *
92 * @param target The new target frame
93 */
94 public void setTarget(String target) {
95
96 this.target = target;
97
98 }
99
100
101
102
103
104 /**
105 * <p>Restore the state of this component.</p>
106 *
107 * @param context <code>FacesContext</code> for the current request
108 * @param state State object from which to restore our state
109 */
110 public void restoreState(FacesContext context, Object state) {
111
112 Object values[] = (Object[]) state;
113 super.restoreState(context, values[0]);
114 target = (String) values[1];
115
116 }
117
118
119 /**
120 * <p>Save the state of this component.</p>
121 *
122 * @param context <code>FacesContext</code> for the current request
123 */
124 public Object saveState(FacesContext context) {
125
126 Object values[] = new Object[2];
127 values[0] = super.saveState(context);
128 values[1] = target;
129 return values;
130
131 }
132
133
134 }