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