~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to contrib/struts-faces/core-library/src/java/org/apache/struts/faces/taglib/CommandLinkTag.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2002-2004 The Apache Software Foundation.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
package org.apache.struts.faces.taglib;
 
18
 
 
19
 
 
20
import javax.faces.component.ActionSource;
 
21
import javax.faces.component.UIComponent;
 
22
import javax.faces.context.FacesContext;
 
23
import javax.faces.el.MethodBinding;
 
24
 
 
25
 
 
26
/**
 
27
 * <p>Render a <code>CommandLinkComponent</code> inside a
 
28
 * Struts-Faces <code>FormComponent</code>.</p>
 
29
 *
 
30
 * @version $Rev: 54934 $ $Date: 2004-10-16 18:07:50 +0100 (Sat, 16 Oct 2004) $
 
31
 */
 
32
 
 
33
public class CommandLinkTag extends AbstractFacesTag {
 
34
 
 
35
 
 
36
    // ------------------------------------------------------ Instance Variables
 
37
 
 
38
 
 
39
    private String accesskey = null;
 
40
    private String action = null;
 
41
    private String charset = null;
 
42
    private String dir = null;
 
43
    private String hreflang = null;
 
44
    private String immediate = null;
 
45
    private String lang = null;
 
46
    private String onblur = null;
 
47
    private String onclick = null;
 
48
    private String ondblclick = null;
 
49
    private String onfocus = null;
 
50
    private String onkeydown = null;
 
51
    private String onkeypress = null;
 
52
    private String onkeyup = null;
 
53
    private String onmousedown = null;
 
54
    private String onmousemove = null;
 
55
    private String onmouseout = null;
 
56
    private String onmouseover = null;
 
57
    private String onmouseup = null;
 
58
    private String rel = null;
 
59
    private String rev = null;
 
60
    private String style = null;
 
61
    private String styleClass = null;
 
62
    private String tabindex = null;
 
63
    private String target = null;
 
64
    private String title = null;
 
65
    private String type = null;
 
66
 
 
67
 
 
68
    // ---------------------------------------------------------- Tag Attributes
 
69
 
 
70
 
 
71
    public void setAccesskey(String accesskey) {
 
72
        this.accesskey = accesskey;
 
73
    }
 
74
 
 
75
 
 
76
    public void setAction(String action) {
 
77
        this.action = action;
 
78
    }
 
79
 
 
80
 
 
81
    public void setCharset(String charset) {
 
82
        this.charset = charset;
 
83
    }
 
84
 
 
85
 
 
86
    public void setDir(String dir) {
 
87
        this.dir = dir;
 
88
    }
 
89
 
 
90
 
 
91
    public void setHreflang(String hreflang) {
 
92
        this.hreflang = hreflang;
 
93
    }
 
94
 
 
95
 
 
96
    public void setImmediate(String immediate) {
 
97
        this.immediate = immediate;
 
98
    }
 
99
 
 
100
 
 
101
    public void setLang(String lang) {
 
102
        this.lang = lang;
 
103
    }
 
104
 
 
105
 
 
106
    public void setOnblur(String onblur) {
 
107
        this.onblur = onblur;
 
108
    }
 
109
 
 
110
 
 
111
    public void setOnclick(String onclick) {
 
112
        this.onclick = onclick;
 
113
    }
 
114
 
 
115
 
 
116
    public void setOndblclick(String ondblclick) {
 
117
        this.ondblclick = ondblclick;
 
118
    }
 
119
 
 
120
 
 
121
    public void setOnfocus(String onfocus) {
 
122
        this.onfocus = onfocus;
 
123
    }
 
124
 
 
125
 
 
126
    public void setOnkeydown(String onkeydown) {
 
127
        this.onkeydown = onkeydown;
 
128
    }
 
129
 
 
130
 
 
131
    public void setOnkeypress(String onkeypress) {
 
132
        this.onkeypress = onkeypress;
 
133
    }
 
134
 
 
135
 
 
136
    public void setOnkeyup(String onkeyup) {
 
137
        this.onkeyup = onkeyup;
 
138
    }
 
139
 
 
140
 
 
141
    public void setOnmousedown(String onmousedown) {
 
142
        this.onmousedown = onmousedown;
 
143
    }
 
144
 
 
145
 
 
146
    public void setOnmousemove(String onmousemove) {
 
147
        this.onmousemove = onmousemove;
 
148
    }
 
149
 
 
150
 
 
151
    public void setOnmouseout(String onmouseout) {
 
152
        this.onmouseout = onmouseout;
 
153
    }
 
154
 
 
155
 
 
156
    public void setOnmouseover(String onmouseover) {
 
157
        this.onmouseover = onmouseover;
 
158
    }
 
159
 
 
160
 
 
161
    public void setOnmouseup(String onmouseup) {
 
162
        this.onmouseup = onmouseup;
 
163
    }
 
164
 
 
165
 
 
166
    public void setRel(String rel) {
 
167
        this.rel = rel;
 
168
    }
 
169
 
 
170
 
 
171
    public void setRev(String rev) {
 
172
        this.rev = rev;
 
173
    }
 
174
 
 
175
 
 
176
    public void setStyle(String style) {
 
177
        this.style = style;
 
178
    }
 
179
 
 
180
 
 
181
    public void setStyleClass(String styleClass) {
 
182
        this.styleClass = styleClass;
 
183
    }
 
184
 
 
185
 
 
186
    public void setTabindex(String tabindex) {
 
187
        this.tabindex = tabindex;
 
188
    }
 
189
 
 
190
 
 
191
    public void setTarget(String target) {
 
192
        this.target = target;
 
193
    }
 
194
 
 
195
 
 
196
    public void setTitle(String title) {
 
197
        this.title = title;
 
198
    }
 
199
 
 
200
 
 
201
    public void setType(String type) {
 
202
        this.type = type;
 
203
    }
 
204
 
 
205
 
 
206
    // ------------------------------------------------------------- Tag Methods
 
207
 
 
208
 
 
209
    /**
 
210
     * <p>Release any allocated resources.</p>
 
211
     */
 
212
    public void release() {
 
213
 
 
214
        super.release();
 
215
        accesskey = null;
 
216
        action = null;
 
217
        charset = null;
 
218
        dir = null;
 
219
        hreflang = null;
 
220
        immediate = null;
 
221
        lang = null;
 
222
        onblur = null;
 
223
        onclick = null;
 
224
        ondblclick = null;
 
225
        onfocus = null;
 
226
        onkeydown = null;
 
227
        onkeypress = null;
 
228
        onkeyup = null;
 
229
        onmousedown = null;
 
230
        onmousemove = null;
 
231
        onmouseout = null;
 
232
        onmouseover = null;
 
233
        onmouseup = null;
 
234
        rel = null;
 
235
        rev = null;
 
236
        style = null;
 
237
        styleClass = null;
 
238
        tabindex = null;
 
239
        target = null;
 
240
        title = null;
 
241
        type = null;
 
242
 
 
243
    }
 
244
 
 
245
 
 
246
    // ---------------------------------------------------------- Public Methods
 
247
 
 
248
 
 
249
    /**
 
250
     * <p>Return the type of component to be created for this tag.</p>
 
251
     */
 
252
    public String getComponentType() {
 
253
 
 
254
        return ("org.apache.struts.faces.CommandLink");
 
255
 
 
256
    }
 
257
 
 
258
 
 
259
    /**
 
260
     * <p>Return the <code>rendererType</code> to be used for rendering
 
261
     * our component.</p>
 
262
     */
 
263
    public String getRendererType() {
 
264
 
 
265
        return ("org.apache.struts.faces.CommandLink");
 
266
 
 
267
    }
 
268
 
 
269
 
 
270
    // ------------------------------------------------------- Protected Methods
 
271
 
 
272
 
 
273
    /**
 
274
     * <p>Override attributes set on this tag instance.</p>
 
275
     *
 
276
     * @param component Component whose attributes should be overridden
 
277
     */
 
278
    protected void setProperties(UIComponent component) {
 
279
 
 
280
        super.setProperties(component);
 
281
        if (action != null) {
 
282
            if (isValueReference(action)) {
 
283
                MethodBinding mb = FacesContext.getCurrentInstance().
 
284
                    getApplication().createMethodBinding(action, null);
 
285
                ((ActionSource) component).setAction(mb);
 
286
            } else {
 
287
                final String outcome = action;
 
288
                MethodBinding mb = new ConstantMethodBinding(outcome);
 
289
                ((ActionSource) component).setAction(mb);
 
290
            }
 
291
        }
 
292
        setStringAttribute(component, "accesskey", accesskey);
 
293
        setStringAttribute(component, "charset", charset);
 
294
        setStringAttribute(component, "dir", dir);
 
295
        setStringAttribute(component, "hreflang", hreflang);
 
296
        setBooleanAttribute(component, "immediate", immediate);
 
297
        setStringAttribute(component, "lang", lang);
 
298
        setStringAttribute(component, "onblur", onblur);
 
299
        setStringAttribute(component, "onclick", onclick);
 
300
        setStringAttribute(component, "ondblclick", ondblclick);
 
301
        setStringAttribute(component, "onfocus", onfocus);
 
302
        setStringAttribute(component, "onkeydown", onkeydown);
 
303
        setStringAttribute(component, "onkeypress", onkeypress);
 
304
        setStringAttribute(component, "onkeyup", onkeyup);
 
305
        setStringAttribute(component, "onmousedown", onmousedown);
 
306
        setStringAttribute(component, "onmousemove", onmousemove);
 
307
        setStringAttribute(component, "onmouseout", onmouseout);
 
308
        setStringAttribute(component, "onmouseover", onmouseover);
 
309
        setStringAttribute(component, "onmouseup", onmouseup);
 
310
        setStringAttribute(component, "rel", rel);
 
311
        setStringAttribute(component, "rev", rev);
 
312
        setStringAttribute(component, "style", style);
 
313
        setStringAttribute(component, "styleClass", styleClass);
 
314
        setStringAttribute(component, "tabindex", tabindex);
 
315
        setStringAttribute(component, "target", target);
 
316
        setStringAttribute(component, "title", title);
 
317
        setStringAttribute(component, "type", type);
 
318
 
 
319
    }
 
320
 
 
321
 
 
322
}
 
323
 
 
324
 
 
325
// Private MethodBinding Implementation To Return A Constant Value
 
326
 
 
327
class ConstantMethodBinding extends MethodBinding {
 
328
 
 
329
    public ConstantMethodBinding(String outcome) {
 
330
        this.outcome = outcome;
 
331
    }
 
332
 
 
333
    private String outcome = null;
 
334
 
 
335
    public Object invoke(FacesContext context, Object params[]) {
 
336
        return (this.outcome);
 
337
    }
 
338
 
 
339
    public Class getType(FacesContext context) {
 
340
        return (String.class);
 
341
    }
 
342
 
 
343
 
 
344
}