001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.component;
021
022 import org.apache.commons.logging.Log;
023 import org.apache.commons.logging.LogFactory;
024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DEFAULT_COMMAND;
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
026 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
027 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
028 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
029 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
030 import org.apache.myfaces.tobago.component.ComponentUtil;
031 import org.apache.myfaces.tobago.component.UILinkCommand;
032 import org.apache.myfaces.tobago.util.Deprecation;
033
034 import javax.faces.component.UIComponent;
035
036 public class LinkTag extends AbstractCommandTag
037 implements LinkTagDeclaration {
038
039 private static final Log LOG = LogFactory.getLog(LinkTag.class);
040
041 private String target;
042 private String label;
043 private String image;
044 private String tip;
045 private String defaultCommand;
046 private String markup;
047 private String tabIndex;
048
049 protected void setProperties(UIComponent component) {
050 super.setProperties(component);
051 ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
052 ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
053 ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
054 ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
055 ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
056 ComponentUtil.setMarkup(component, markup);
057 ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
058 }
059
060 public String getComponentType() {
061 return UILinkCommand.COMPONENT_TYPE;
062 }
063
064 public void release() {
065 super.release();
066 target = null;
067 label = null;
068 image = null;
069 tip = null;
070 defaultCommand = null;
071 markup = null;
072 tabIndex = null;
073 }
074
075 public String getTarget() {
076 return target;
077 }
078
079 public void setTarget(String target) {
080 this.target = target;
081 }
082
083 public String getLabel() {
084 return label;
085 }
086
087 public void setLabel(String label) {
088 this.label = label;
089 }
090
091 public String getImage() {
092 return image;
093 }
094
095 public void setImage(String image) {
096 this.image = image;
097 }
098
099 public String getAccessKey() {
100 return null;
101 }
102
103 public void setAccessKey(String accessKey) {
104 if (Deprecation.LOG.isErrorEnabled()) {
105 Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
106 + "and will removed soon! Please use special syntax of 'label' instead.");
107 }
108 }
109
110 public String getLabelWithAccessKey() {
111 return null;
112 }
113
114 public void setLabelWithAccessKey(String labelWithAccessKey) {
115 if (Deprecation.LOG.isWarnEnabled()) {
116 Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
117 + "and will removed soon! Please use 'label' instead.");
118 }
119 setLabel(labelWithAccessKey);
120 }
121
122 public void setTip(String tip) {
123 this.tip = tip;
124 }
125
126 public void setDefaultCommand(String defaultCommand) {
127 this.defaultCommand = defaultCommand;
128 }
129
130 public void setMarkup(String markup) {
131 this.markup = markup;
132 }
133
134 public void setTabIndex(String tabIndex) {
135 this.tabIndex = tabIndex;
136 }
137 }