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      private String markup;
035    
036    
037      @Override
038      public String getComponentType() {
039        return UILabel.COMPONENT_TYPE;
040      }
041    
042      public String getFor() {
043        return forComponent;
044      }
045    
046      @Override
047      public void release() {
048        super.release();
049        tip = null;
050        forComponent = null;
051        markup = null;
052      }
053    
054      public void setFor(String forComponent) {
055        this.forComponent = forComponent;
056      }
057    
058      @Override
059      protected void setProperties(UIComponent component) {
060        super.setProperties(component);
061        ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent);
062        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
063        ComponentUtil.setMarkup(component, markup);
064      }
065    
066      public String getAccessKey() {
067        return null;
068      }
069    
070      public void setAccessKey(String accessKey) {
071        LOG.warn("Attibute 'accessKey' is deprecated, "
072            + "and will removed soon!");
073      }
074    
075      public String getLabelWithAccessKey() {
076        return null;
077      }
078    
079      public void setLabelWithAccessKey(String labelWithAccessKey) {
080        LOG.warn("Attibute 'labelWithAccessKey' is deprecated, "
081            + "and will removed soon! Please use 'label' instead.");
082        setLabel(labelWithAccessKey);
083      }
084    
085      public String getTip() {
086        return tip;
087      }
088    
089      public void setTip(String tip) {
090        this.tip = tip;
091      }
092    
093      public String getMarkup() {
094        return markup;
095      }
096    
097      public void setMarkup(String markup) {
098        this.markup = markup;
099      }
100    }
101