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