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    
027    import javax.faces.component.UIComponent;
028    
029    public class LabelTag extends BeanTag implements LabelTagDeclaration {
030      private static final Log LOG = LogFactory.getLog(LabelTag.class);
031    
032      private String forComponent;
033      private String tip;
034    
035      @Override
036      public String getComponentType() {
037        return UILabel.COMPONENT_TYPE;
038      }
039    
040      public String getFor() {
041        return forComponent;
042      }
043    
044      @Override
045      public void release() {
046        super.release();
047        tip = null;
048        forComponent = null;
049      }
050    
051      public void setFor(String forComponent) {
052        this.forComponent = forComponent;
053      }
054    
055      @Override
056      protected void setProperties(UIComponent component) {
057        super.setProperties(component);
058        ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent);
059        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
060      }
061    
062      public String getAccessKey() {
063        return null;
064      }
065    
066      public void setAccessKey(String accessKey) {
067        LOG.warn("Attibute 'accessKey' is deprecated, "
068            + "and will removed soon!");
069      }
070    
071      public String getLabelWithAccessKey() {
072        return null;
073      }
074    
075      public void setLabelWithAccessKey(String labelWithAccessKey) {
076        LOG.warn("Attibute 'labelWithAccessKey' is deprecated, "
077            + "and will removed soon! Please use 'label' instead.");
078        setLabel(labelWithAccessKey);
079      }
080    
081      public String getTip() {
082        return tip;
083      }
084    
085      public void setTip(String tip) {
086        this.tip = tip;
087      }
088    }
089