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