1 /* 2 * $Id: LinkSubscriptionTag.java 471754 2006-11-06 14:55:09Z husted $ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 23 package org.apache.struts.webapp.example2; 24 25 26 import javax.faces.component.UIComponent; 27 import javax.faces.el.ValueBinding; 28 import javax.faces.webapp.UIComponentTag; 29 30 31 /** 32 * Generate a URL-encoded hyperlink to the specified URI, with 33 * associated query parameters selecting a specified Subscription. 34 * 35 * @author Craig R. McClanahan 36 * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $ 37 */ 38 39 public class LinkSubscriptionTag extends UIComponentTag { 40 41 42 // -------------------------------------------------------------- Attributes 43 44 45 /** 46 * The attribute name. 47 */ 48 protected String name = "subscription"; 49 50 public void setName(String name) { 51 this.name = name; 52 } 53 54 55 /** 56 * The context-relative URI. 57 */ 58 protected String page = null; 59 60 public void setPage(String page) { 61 this.page = page; 62 } 63 64 65 // ---------------------------------------------------------- Public Methods 66 67 68 /** 69 * Return the component type for this tag.</p> 70 */ 71 public String getComponentType() { 72 73 return ("Output"); 74 75 } 76 77 78 /** 79 * <p>Return the renderer type associated with this tag.</p> 80 */ 81 public String getRendererType() { 82 83 return ("LinkSubscription"); 84 85 } 86 87 88 /** 89 * <p>Release resources allocated to this tag instance.</p> 90 */ 91 public void release() { 92 93 super.release(); 94 this.name = "subscription"; 95 this.page = null; 96 97 } 98 99 100 // ------------------------------------------------------- Protected Methods 101 102 103 /** 104 * <p>Override attributes set on this tag instance.</p> 105 * 106 * @param component Component whose attributes should be overridden 107 */ 108 protected void setProperties(UIComponent component) { 109 110 super.setProperties(component); 111 if (name != null) { 112 if (isValueReference(name)) { 113 ValueBinding vb = 114 getFacesContext().getApplication().createValueBinding(name); 115 component.setValueBinding("name", vb); 116 } else { 117 component.getAttributes().put("name", name); 118 } 119 } 120 if (page != null) { 121 if (isValueReference(page)) { 122 ValueBinding vb = 123 getFacesContext().getApplication().createValueBinding(page); 124 component.setValueBinding("page", vb); 125 } else { 126 component.getAttributes().put("page", page); 127 } 128 } 129 130 } 131 132 133 }