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 578592 2007-09-23 18:51:32Z 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_TAB_INDEX;
031    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
032    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
033    import org.apache.myfaces.tobago.component.ComponentUtil;
034    import org.apache.myfaces.tobago.component.UIButtonCommand;
035    
036    import javax.faces.component.UIComponent;
037    
038    /**
039     * Renders a button element.
040     */
041    // FIXME: bodyContent
042    public class ButtonTag extends AbstractCommandTag
043        implements ButtonTagDeclaration {
044    
045      private static final Log LOG = LogFactory.getLog(ButtonTag.class);
046    
047      private String label;
048      private String image;
049      private String tip;
050      private String defaultCommand;
051      private String target;
052      private String markup;
053      private String tabIndex;
054    
055      @Override
056      protected void setProperties(UIComponent component) {
057        super.setProperties(component);
058        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
059        ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
060        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
061        ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
062        ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
063        ComponentUtil.setMarkup(component, markup);
064        ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
065      }
066    
067       public String getComponentType() {
068        return UIButtonCommand.COMPONENT_TYPE;
069      }
070    
071      @Override
072      public void release() {
073        super.release();
074        label = null;
075        image = null;
076        tip = null;
077        defaultCommand = null;
078        target = null;
079        markup = null;
080        tabIndex = null;
081      }
082    
083      public String getAccessKey() {
084        return null;
085      }
086    
087      public void setAccessKey(String accessKey) {
088        LOG.warn("Attibute 'accessKey' is deprecated, "
089            + "and will removed soon!");
090      }
091    
092      public String getImage() {
093        return image;
094      }
095    
096      public void setImage(String image) {
097        this.image = image;
098      }
099    
100      @Override
101      public String getLabel() {
102        return label;
103      }
104    
105      @Override
106      public void setLabel(String label) {
107        this.label = label;
108      }
109    
110      public String getLabelWithAccessKey() {
111        return null;
112      }
113    
114      public void setLabelWithAccessKey(String labelWithAccessKey) {
115        LOG.warn("Attibute 'labelWithAccessKey' is deprecated, "
116            + "and will removed soon! Please use 'label' instead.");
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 setTarget(String target) {
129        this.target = target;
130      }
131    
132      public void setMarkup(String markup) {
133        this.markup = markup;
134      }
135    
136      public void setTabIndex(String tabIndex) {
137        this.tabIndex = tabIndex;
138      }
139    }
140