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_DEFAULT_COMMAND;
023    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
024    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
025    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
026    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
027    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
028    import org.apache.myfaces.tobago.component.ComponentUtil;
029    import org.apache.myfaces.tobago.component.UILinkCommand;
030    import org.apache.myfaces.tobago.util.Deprecation;
031    
032    import javax.faces.component.UIComponent;
033    
034    public class LinkTag extends AbstractCommandTag
035        implements LinkTagDeclaration {
036    
037      private static final Log LOG = LogFactory.getLog(LinkTag.class);
038    
039      private String target;
040      private String label;
041      private String image;
042      private String tip;
043      private String defaultCommand;
044      private String markup;
045      private String tabIndex;
046    
047      protected void setProperties(UIComponent component) {
048        super.setProperties(component);
049        ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
050        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
051        ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
052        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
053        ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
054        ComponentUtil.setMarkup(component, markup);
055        ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
056      }
057    
058      public String getComponentType() {
059        return UILinkCommand.COMPONENT_TYPE;
060      }
061    
062      public void release() {
063        super.release();
064        target = null;
065        label = null;
066        image = null;
067        tip = null;
068        defaultCommand = null;
069        markup = null;
070        tabIndex = null;
071      }
072    
073      public String getTarget() {
074        return target;
075      }
076    
077      public void setTarget(String target) {
078        this.target = target;
079      }
080    
081      public String getLabel() {
082        return label;
083      }
084    
085      public void setLabel(String label) {
086        this.label = label;
087      }
088    
089      public String getImage() {
090        return image;
091      }
092    
093      public void setImage(String image) {
094        this.image = image;
095      }
096    
097      public String getAccessKey() {
098        return null;
099      }
100    
101      public void setAccessKey(String accessKey) {
102        if (Deprecation.LOG.isErrorEnabled()) {
103          Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
104              + "and will removed soon! Please use special syntax of 'label' instead.");
105        }
106      }
107    
108      public String getLabelWithAccessKey() {
109        return null;
110      }
111    
112      public void setLabelWithAccessKey(String labelWithAccessKey) {
113        if (Deprecation.LOG.isWarnEnabled()) {
114          Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
115              + "and will removed soon! Please use 'label' instead.");
116        }
117        setLabel(labelWithAccessKey);
118      }
119    
120      public void setTip(String tip) {
121        this.tip = tip;
122      }
123    
124      public void setDefaultCommand(String defaultCommand) {
125        this.defaultCommand = defaultCommand;
126      }
127    
128      public void setMarkup(String markup) {
129        this.markup = markup;
130      }
131    
132      public void setTabIndex(String tabIndex) {
133        this.tabIndex = tabIndex;
134      }
135    }