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