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    /*
021     * Created on: 15.02.2002, 17:01:56
022     * $Id: ButtonTag.java 509102 2007-02-19 06:10:09Z bommel $
023     */
024    
025    import org.apache.commons.logging.Log;
026    import org.apache.commons.logging.LogFactory;
027    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DEFAULT_COMMAND;
028    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
029    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
030    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
031    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
032    import org.apache.myfaces.tobago.component.ComponentUtil;
033    import org.apache.myfaces.tobago.component.UIButtonCommand;
034    
035    import javax.faces.component.UIComponent;
036    
037    /**
038     * Renders a button element.
039     */
040    // FIXME: bodyContent
041    public class ButtonTag extends AbstractCommandTag
042        implements ButtonTagDeclaration {
043    
044      private static final Log LOG = LogFactory.getLog(ButtonTag.class);
045    
046      private String label;
047      private String image;
048      private String tip;
049      private String defaultCommand;
050      private String target;
051      private String markup;
052    
053      @Override
054      protected void setProperties(UIComponent component) {
055        super.setProperties(component);
056        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
057        ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
058        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
059        ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
060        ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
061        ComponentUtil.setMarkup(component, markup);
062      }
063    
064       public String getComponentType() {
065        return UIButtonCommand.COMPONENT_TYPE;
066      }
067    
068      @Override
069      public void release() {
070        super.release();
071        label = null;
072        image = null;
073        tip = null;
074        defaultCommand = null;
075        target = null;
076        markup = null;
077      }
078    
079      public String getAccessKey() {
080        return null;
081      }
082    
083      public void setAccessKey(String accessKey) {
084        LOG.warn("Attibute 'accessKey' is deprecated, "
085            + "and will removed soon!");
086      }
087    
088      public String getImage() {
089        return image;
090      }
091    
092      public void setImage(String image) {
093        this.image = image;
094      }
095    
096      @Override
097      public String getLabel() {
098        return label;
099      }
100    
101      @Override
102      public void setLabel(String label) {
103        this.label = label;
104      }
105    
106      public String getLabelWithAccessKey() {
107        return null;
108      }
109    
110      public void setLabelWithAccessKey(String labelWithAccessKey) {
111        LOG.warn("Attibute 'labelWithAccessKey' is deprecated, "
112            + "and will removed soon! Please use 'label' instead.");
113        setLabel(labelWithAccessKey);
114      }
115    
116      public void setTip(String tip) {
117        this.tip = tip;
118      }
119    
120      public void setDefaultCommand(String defaultCommand) {
121        this.defaultCommand = defaultCommand;
122      }
123    
124      public void setTarget(String target) {
125        this.target = target;
126      }
127    
128      public void setMarkup(String markup) {
129        this.markup = markup;
130      }
131    }
132