001: /*
002: * $Id: CommandLinkComponent.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: package org.apache.struts.faces.component;
023:
024: import javax.faces.component.UICommand;
025: import javax.faces.context.FacesContext;
026: import javax.faces.el.ValueBinding;
027:
028: /**
029: * <p>Custom component that emulates the JSF standard component class
030: * <code>javax.faces.component.html.HtmlCommandLink</code> (and its
031: * corresponding renderer) but is not tied to a particular implementation of
032: * renderer for <code>javax.faces.component.UIForm</code>.</p>
033: */
034:
035: public class CommandLinkComponent extends UICommand {
036:
037: // ------------------------------------------------------------ Constructors
038:
039: /**
040: * <p>Create a new {@link CommandLinkComponent} with default properties.</p>
041: */
042: public CommandLinkComponent() {
043:
044: super ();
045: setRendererType("org.apache.struts.faces.CommandLink");
046:
047: }
048:
049: // ------------------------------------------------------ Instance Variables
050:
051: private String accesskey = null;
052: private String charset = null;
053: private String dir = null;
054: private String hreflang = null;
055: private String lang = null;
056: private String onblur = null;
057: private String onclick = null;
058: private String ondblclick = null;
059: private String onfocus = null;
060: private String onkeydown = null;
061: private String onkeypress = null;
062: private String onkeyup = null;
063: private String onmousedown = null;
064: private String onmousemove = null;
065: private String onmouseout = null;
066: private String onmouseover = null;
067: private String onmouseup = null;
068: private String rel = null;
069: private String rev = null;
070: private String style = null;
071: private String styleClass = null;
072: private String tabindex = null;
073: private String target = null;
074: private String title = null;
075: private String type = null;
076:
077: // ---------------------------------------------------- Component Properties
078:
079: public String getAccesskey() {
080: ValueBinding vb = getValueBinding("accesskey");
081: if (vb != null) {
082: return (String) vb.getValue(getFacesContext());
083: } else {
084: return accesskey;
085: }
086: }
087:
088: public void setAccesskey(String accesskey) {
089: this .accesskey = accesskey;
090: }
091:
092: public String getCharset() {
093: ValueBinding vb = getValueBinding("charset");
094: if (vb != null) {
095: return (String) vb.getValue(getFacesContext());
096: } else {
097: return charset;
098: }
099: }
100:
101: public void setCharset(String charset) {
102: this .charset = charset;
103: }
104:
105: public String getDir() {
106: ValueBinding vb = getValueBinding("dir");
107: if (vb != null) {
108: return (String) vb.getValue(getFacesContext());
109: } else {
110: return dir;
111: }
112: }
113:
114: public void setDir(String dir) {
115: this .dir = dir;
116: }
117:
118: /**
119: * <p>Return the component family to which this component belongs.</p>
120: */
121: public String getFamily() {
122:
123: return "org.apache.struts.faces.CommandLink";
124:
125: }
126:
127: public String getHreflang() {
128: ValueBinding vb = getValueBinding("hreflang");
129: if (vb != null) {
130: return (String) vb.getValue(getFacesContext());
131: } else {
132: return hreflang;
133: }
134: }
135:
136: public void setHreflang(String hreflang) {
137: this .hreflang = hreflang;
138: }
139:
140: public String getLang() {
141: ValueBinding vb = getValueBinding("lang");
142: if (vb != null) {
143: return (String) vb.getValue(getFacesContext());
144: } else {
145: return lang;
146: }
147: }
148:
149: public void setLang(String lang) {
150: this .lang = lang;
151: }
152:
153: public String getOnblur() {
154: ValueBinding vb = getValueBinding("onblur");
155: if (vb != null) {
156: return (String) vb.getValue(getFacesContext());
157: } else {
158: return onblur;
159: }
160: }
161:
162: public void setOnblur(String onblur) {
163: this .onblur = onblur;
164: }
165:
166: public String getOnclick() {
167: ValueBinding vb = getValueBinding("onclick");
168: if (vb != null) {
169: return (String) vb.getValue(getFacesContext());
170: } else {
171: return onclick;
172: }
173: }
174:
175: public void setOnclick(String onclick) {
176: this .onclick = onclick;
177: }
178:
179: public String getOndblclick() {
180: ValueBinding vb = getValueBinding("ondblclick");
181: if (vb != null) {
182: return (String) vb.getValue(getFacesContext());
183: } else {
184: return ondblclick;
185: }
186: }
187:
188: public void setOndblclick(String ondblclick) {
189: this .ondblclick = ondblclick;
190: }
191:
192: public String getOnfocus() {
193: ValueBinding vb = getValueBinding("onfocus");
194: if (vb != null) {
195: return (String) vb.getValue(getFacesContext());
196: } else {
197: return onfocus;
198: }
199: }
200:
201: public void setOnfocus(String onfocus) {
202: this .onfocus = onfocus;
203: }
204:
205: public String getOnkeydown() {
206: ValueBinding vb = getValueBinding("onkeydown");
207: if (vb != null) {
208: return (String) vb.getValue(getFacesContext());
209: } else {
210: return onkeydown;
211: }
212: }
213:
214: public void setOnkeydown(String onkeydown) {
215: this .onkeydown = onkeydown;
216: }
217:
218: public String getOnkeypress() {
219: ValueBinding vb = getValueBinding("onkeypress");
220: if (vb != null) {
221: return (String) vb.getValue(getFacesContext());
222: } else {
223: return onkeypress;
224: }
225: }
226:
227: public void setOnkeypress(String onkeypress) {
228: this .onkeypress = onkeypress;
229: }
230:
231: public String getOnkeyup() {
232: ValueBinding vb = getValueBinding("onkeyup");
233: if (vb != null) {
234: return (String) vb.getValue(getFacesContext());
235: } else {
236: return onkeyup;
237: }
238: }
239:
240: public void setOnkeyup(String onkeyup) {
241: this .onkeyup = onkeyup;
242: }
243:
244: public String getOnmousedown() {
245: ValueBinding vb = getValueBinding("onmousedown");
246: if (vb != null) {
247: return (String) vb.getValue(getFacesContext());
248: } else {
249: return onmousedown;
250: }
251: }
252:
253: public void setOnmousedown(String onmousedown) {
254: this .onmousedown = onmousedown;
255: }
256:
257: public String getOnmousemove() {
258: ValueBinding vb = getValueBinding("onmousemove");
259: if (vb != null) {
260: return (String) vb.getValue(getFacesContext());
261: } else {
262: return onmousemove;
263: }
264: }
265:
266: public void setOnmousemove(String onmousemove) {
267: this .onmousemove = onmousemove;
268: }
269:
270: public String getOnmouseout() {
271: ValueBinding vb = getValueBinding("onmouseout");
272: if (vb != null) {
273: return (String) vb.getValue(getFacesContext());
274: } else {
275: return onmouseout;
276: }
277: }
278:
279: public void setOnmouseout(String onmouseout) {
280: this .onmouseout = onmouseout;
281: }
282:
283: public String getOnmouseover() {
284: ValueBinding vb = getValueBinding("onmouseover");
285: if (vb != null) {
286: return (String) vb.getValue(getFacesContext());
287: } else {
288: return onmouseover;
289: }
290: }
291:
292: public void setOnmouseover(String onmouseover) {
293: this .onmouseover = onmouseover;
294: }
295:
296: public String getOnmouseup() {
297: ValueBinding vb = getValueBinding("onmouseup");
298: if (vb != null) {
299: return (String) vb.getValue(getFacesContext());
300: } else {
301: return onmouseup;
302: }
303: }
304:
305: public void setOnmouseup(String onmouseup) {
306: this .onmouseup = onmouseup;
307: }
308:
309: public String getRel() {
310: ValueBinding vb = getValueBinding("rel");
311: if (vb != null) {
312: return (String) vb.getValue(getFacesContext());
313: } else {
314: return rel;
315: }
316: }
317:
318: public void setRel(String rel) {
319: this .rel = rel;
320: }
321:
322: public String getRev() {
323: ValueBinding vb = getValueBinding("rev");
324: if (vb != null) {
325: return (String) vb.getValue(getFacesContext());
326: } else {
327: return rev;
328: }
329: }
330:
331: public void setRev(String rev) {
332: this .rev = rev;
333: }
334:
335: public String getStyle() {
336: ValueBinding vb = getValueBinding("style");
337: if (vb != null) {
338: return (String) vb.getValue(getFacesContext());
339: } else {
340: return style;
341: }
342: }
343:
344: public void setStyle(String style) {
345: this .style = style;
346: }
347:
348: public String getStyleClass() {
349: ValueBinding vb = getValueBinding("styleClass");
350: if (vb != null) {
351: return (String) vb.getValue(getFacesContext());
352: } else {
353: return styleClass;
354: }
355: }
356:
357: public void setStyleClass(String styleClass) {
358: this .styleClass = styleClass;
359: }
360:
361: public String getTabindex() {
362: ValueBinding vb = getValueBinding("tabindex");
363: if (vb != null) {
364: return (String) vb.getValue(getFacesContext());
365: } else {
366: return tabindex;
367: }
368: }
369:
370: public void setTabindex(String tabindex) {
371: this .tabindex = tabindex;
372: }
373:
374: public String getTarget() {
375: ValueBinding vb = getValueBinding("target");
376: if (vb != null) {
377: return (String) vb.getValue(getFacesContext());
378: } else {
379: return target;
380: }
381: }
382:
383: public void setTarget(String target) {
384: this .target = target;
385: }
386:
387: public String getTitle() {
388: ValueBinding vb = getValueBinding("title");
389: if (vb != null) {
390: return (String) vb.getValue(getFacesContext());
391: } else {
392: return title;
393: }
394: }
395:
396: public void setTitle(String title) {
397: this .title = title;
398: }
399:
400: public String getType() {
401: ValueBinding vb = getValueBinding("type");
402: if (vb != null) {
403: return (String) vb.getValue(getFacesContext());
404: } else {
405: return type;
406: }
407: }
408:
409: public void setType(String type) {
410: this .type = type;
411: }
412:
413: // ---------------------------------------------------- StateManager Methods
414:
415: /**
416: * <p>Restore the state of this component.</p>
417: *
418: * @param context <code>FacesContext</code> for the current request
419: * @param state State object from which to restore our state
420: */
421: public void restoreState(FacesContext context, Object state) {
422:
423: Object values[] = (Object[]) state;
424: super .restoreState(context, values[0]);
425: accesskey = (String) values[1];
426: charset = (String) values[2];
427: dir = (String) values[3];
428: hreflang = (String) values[4];
429: lang = (String) values[5];
430: onblur = (String) values[6];
431: onclick = (String) values[7];
432: ondblclick = (String) values[8];
433: onfocus = (String) values[9];
434: onkeydown = (String) values[10];
435: onkeypress = (String) values[11];
436: onkeyup = (String) values[12];
437: onmousedown = (String) values[13];
438: onmousemove = (String) values[14];
439: onmouseout = (String) values[15];
440: onmouseover = (String) values[16];
441: onmouseup = (String) values[17];
442: rel = (String) values[18];
443: rev = (String) values[19];
444: style = (String) values[20];
445: styleClass = (String) values[21];
446: tabindex = (String) values[22];
447: target = (String) values[23];
448: title = (String) values[24];
449: type = (String) values[25];
450:
451: }
452:
453: /**
454: * <p>Save the state of this component.</p>
455: *
456: * @param context <code>FacesContext</code> for the current request
457: */
458: public Object saveState(FacesContext context) {
459:
460: Object values[] = new Object[26];
461: values[0] = super .saveState(context);
462: values[1] = accesskey;
463: values[2] = charset;
464: values[3] = dir;
465: values[4] = hreflang;
466: values[5] = lang;
467: values[6] = onblur;
468: values[7] = onclick;
469: values[8] = ondblclick;
470: values[9] = onfocus;
471: values[10] = onkeydown;
472: values[11] = onkeypress;
473: values[12] = onkeyup;
474: values[13] = onmousedown;
475: values[14] = onmousemove;
476: values[15] = onmouseout;
477: values[16] = onmouseover;
478: values[17] = onmouseup;
479: values[18] = rel;
480: values[19] = rev;
481: values[20] = style;
482: values[21] = styleClass;
483: values[22] = tabindex;
484: values[23] = target;
485: values[24] = title;
486: values[25] = type;
487: return values;
488:
489: }
490:
491: }
|