1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts.webapp.example2;
24
25
26 import javax.faces.component.UIComponent;
27 import javax.faces.el.ValueBinding;
28 import javax.faces.webapp.UIComponentTag;
29
30
31 /**
32 * Generate a URL-encoded hyperlink to the specified URI, with
33 * associated query parameters selecting a specified Subscription.
34 *
35 * @author Craig R. McClanahan
36 * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
37 */
38
39 public class LinkSubscriptionTag extends UIComponentTag {
40
41
42
43
44
45 /**
46 * The attribute name.
47 */
48 protected String name = "subscription";
49
50 public void setName(String name) {
51 this.name = name;
52 }
53
54
55 /**
56 * The context-relative URI.
57 */
58 protected String page = null;
59
60 public void setPage(String page) {
61 this.page = page;
62 }
63
64
65
66
67
68 /**
69 * Return the component type for this tag.</p>
70 */
71 public String getComponentType() {
72
73 return ("Output");
74
75 }
76
77
78 /**
79 * <p>Return the renderer type associated with this tag.</p>
80 */
81 public String getRendererType() {
82
83 return ("LinkSubscription");
84
85 }
86
87
88 /**
89 * <p>Release resources allocated to this tag instance.</p>
90 */
91 public void release() {
92
93 super.release();
94 this.name = "subscription";
95 this.page = null;
96
97 }
98
99
100
101
102
103 /**
104 * <p>Override attributes set on this tag instance.</p>
105 *
106 * @param component Component whose attributes should be overridden
107 */
108 protected void setProperties(UIComponent component) {
109
110 super.setProperties(component);
111 if (name != null) {
112 if (isValueReference(name)) {
113 ValueBinding vb =
114 getFacesContext().getApplication().createValueBinding(name);
115 component.setValueBinding("name", vb);
116 } else {
117 component.getAttributes().put("name", name);
118 }
119 }
120 if (page != null) {
121 if (isValueReference(page)) {
122 ValueBinding vb =
123 getFacesContext().getApplication().createValueBinding(page);
124 component.setValueBinding("page", vb);
125 } else {
126 component.getAttributes().put("page", page);
127 }
128 }
129
130 }
131
132
133 }