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 803491 2009-08-12 13:19:10Z lofwyr $
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 import org.apache.myfaces.tobago.util.Deprecation;
036
037 import javax.faces.component.UIComponent;
038
039 /**
040 * Renders a button element.
041 */
042 // FIXME: bodyContent
043 public class ButtonTag extends AbstractCommandTag
044 implements ButtonTagDeclaration {
045
046 private static final Log LOG = LogFactory.getLog(ButtonTag.class);
047
048 private String label;
049 private String image;
050 private String tip;
051 private String defaultCommand;
052 private String target;
053 private String markup;
054 private String tabIndex;
055
056 @Override
057 protected void setProperties(UIComponent component) {
058 super.setProperties(component);
059 ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
060 ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
061 ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
062 ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
063 ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
064 ComponentUtil.setMarkup(component, markup);
065 ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
066 }
067
068 public String getComponentType() {
069 return UIButtonCommand.COMPONENT_TYPE;
070 }
071
072 @Override
073 public void release() {
074 super.release();
075 label = null;
076 image = null;
077 tip = null;
078 defaultCommand = null;
079 target = null;
080 markup = null;
081 tabIndex = null;
082 }
083
084 public String getAccessKey() {
085 return null;
086 }
087
088 public void setAccessKey(String accessKey) {
089 if (Deprecation.LOG.isErrorEnabled()) {
090 Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
091 + "and will removed soon! Please use special syntax of 'label' instead.");
092 }
093 }
094
095 public String getImage() {
096 return image;
097 }
098
099 public void setImage(String image) {
100 this.image = image;
101 }
102
103 @Override
104 public String getLabel() {
105 return label;
106 }
107
108 @Override
109 public void setLabel(String label) {
110 this.label = label;
111 }
112
113 public String getLabelWithAccessKey() {
114 return null;
115 }
116
117 public void setLabelWithAccessKey(String labelWithAccessKey) {
118 if (Deprecation.LOG.isWarnEnabled()) {
119 Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
120 + "and will removed soon! Please use 'label' instead.");
121 }
122 setLabel(labelWithAccessKey);
123 }
124
125 public void setTip(String tip) {
126 this.tip = tip;
127 }
128
129 public void setDefaultCommand(String defaultCommand) {
130 this.defaultCommand = defaultCommand;
131 }
132
133 public void setTarget(String target) {
134 this.target = target;
135 }
136
137 public void setMarkup(String markup) {
138 this.markup = markup;
139 }
140
141 public void setTabIndex(String tabIndex) {
142 this.tabIndex = tabIndex;
143 }
144 }
145