View Javadoc

1   /*
2    * Copyright 1999-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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      // -------------------------------------------------------------- Attributes
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      // ---------------------------------------------------------- Public Methods
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      // ------------------------------------------------------- Protected Methods
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 }