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