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