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 jakarta.el.ValueExpression;
26 import jakarta.faces.component.UIOutput;
27 import jakarta.faces.context.FacesContext;
28
29
30
31
32
33
34
35 public class HtmlComponent extends UIOutput {
36
37
38
39
40
41
42
43
44 public HtmlComponent() {
45
46 super();
47 setRendererType("org.apache.struts.faces.Html");
48
49 }
50
51
52
53
54
55
56
57
58 private boolean locale = true;
59 private boolean localeSet = false;
60
61
62
63
64
65 private boolean xhtml = false;
66 private boolean xhtmlSet = false;
67
68
69
70
71
72
73
74
75 public String getFamily() {
76
77 return "org.apache.struts.faces.Html";
78
79 }
80
81
82
83
84
85 public boolean isLocale() {
86
87 if (localeSet) {
88 return locale;
89 }
90 ValueExpression vb = getValueExpression("locale");
91 if (vb != null) {
92 Boolean value = (Boolean) vb.getValue(getFacesContext().getELContext());
93 if (null == value) {
94 return locale;
95 }
96 return value.booleanValue();
97 } else {
98 return locale;
99 }
100
101 }
102
103
104
105
106
107
108
109 public void setLocale(boolean locale) {
110
111 this.locale = locale;
112 this.localeSet = true;
113
114 }
115
116
117
118
119
120 public boolean isXhtml() {
121
122 if (xhtmlSet) {
123 return xhtml;
124 }
125 ValueExpression vb = getValueExpression("xhtml");
126 if (vb != null) {
127 Boolean value = (Boolean) vb.getValue(getFacesContext().getELContext());
128 if (null == value) {
129 return xhtml;
130 }
131 return value.booleanValue();
132 } else {
133 return xhtml;
134 }
135
136 }
137
138
139
140
141
142
143
144 public void setXhtml(boolean xhtml) {
145
146 this.xhtml = xhtml;
147 this.xhtmlSet = true;
148
149 }
150
151
152
153
154
155
156
157
158
159
160
161 public void restoreState(FacesContext context, Object state) {
162
163 Object values[] = (Object[]) state;
164 super.restoreState(context, values[0]);
165 locale = ((Boolean) values[1]).booleanValue();
166 localeSet = ((Boolean) values[2]).booleanValue();
167 xhtml = ((Boolean) values[3]).booleanValue();
168 xhtmlSet = ((Boolean) values[4]).booleanValue();
169
170 }
171
172
173
174
175
176
177
178 public Object saveState(FacesContext context) {
179
180 Object values[] = new Object[5];
181 values[0] = super.saveState(context);
182 values[1] = locale ? Boolean.TRUE : Boolean.FALSE;
183 values[2] = localeSet ? Boolean.TRUE : Boolean.FALSE;
184 values[3] = xhtml ? Boolean.TRUE : Boolean.FALSE;
185 values[4] = xhtmlSet ? Boolean.TRUE : Boolean.FALSE;
186 return values;
187
188 }
189
190
191 }