001: /*
002: * $Id: LinkSubscriptionTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: package org.apache.struts.webapp.example2;
023:
024: import javax.faces.component.UIComponent;
025: import javax.faces.el.ValueBinding;
026: import javax.faces.webapp.UIComponentTag;
027:
028: /**
029: * Generate a URL-encoded hyperlink to the specified URI, with
030: * associated query parameters selecting a specified Subscription.
031: *
032: * @author Craig R. McClanahan
033: * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
034: */
035:
036: public class LinkSubscriptionTag extends UIComponentTag {
037:
038: // -------------------------------------------------------------- Attributes
039:
040: /**
041: * The attribute name.
042: */
043: protected String name = "subscription";
044:
045: public void setName(String name) {
046: this .name = name;
047: }
048:
049: /**
050: * The context-relative URI.
051: */
052: protected String page = null;
053:
054: public void setPage(String page) {
055: this .page = page;
056: }
057:
058: // ---------------------------------------------------------- Public Methods
059:
060: /**
061: * Return the component type for this tag.</p>
062: */
063: public String getComponentType() {
064:
065: return ("Output");
066:
067: }
068:
069: /**
070: * <p>Return the renderer type associated with this tag.</p>
071: */
072: public String getRendererType() {
073:
074: return ("LinkSubscription");
075:
076: }
077:
078: /**
079: * <p>Release resources allocated to this tag instance.</p>
080: */
081: public void release() {
082:
083: super .release();
084: this .name = "subscription";
085: this .page = null;
086:
087: }
088:
089: // ------------------------------------------------------- Protected Methods
090:
091: /**
092: * <p>Override attributes set on this tag instance.</p>
093: *
094: * @param component Component whose attributes should be overridden
095: */
096: protected void setProperties(UIComponent component) {
097:
098: super .setProperties(component);
099: if (name != null) {
100: if (isValueReference(name)) {
101: ValueBinding vb = getFacesContext().getApplication()
102: .createValueBinding(name);
103: component.setValueBinding("name", vb);
104: } else {
105: component.getAttributes().put("name", name);
106: }
107: }
108: if (page != null) {
109: if (isValueReference(page)) {
110: ValueBinding vb = getFacesContext().getApplication()
111: .createValueBinding(page);
112: component.setValueBinding("page", vb);
113: } else {
114: component.getAttributes().put("page", page);
115: }
116: }
117:
118: }
119:
120: }
|