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