001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.component;
021
022 /*
023 * Created on: 15.02.2002, 17:01:56
024 * $Id: ButtonTag.java 1368577 2012-08-02 16:20:31Z lofwyr $
025 */
026
027 import org.apache.commons.logging.Log;
028 import org.apache.commons.logging.LogFactory;
029 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DEFAULT_COMMAND;
030 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
031 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
032 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
033 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
034 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
035 import org.apache.myfaces.tobago.component.ComponentUtil;
036 import org.apache.myfaces.tobago.component.UIButtonCommand;
037 import org.apache.myfaces.tobago.util.Deprecation;
038
039 import javax.faces.component.UIComponent;
040
041 /**
042 * Renders a button element.
043 */
044 // FIXME: bodyContent
045 public class ButtonTag extends AbstractCommandTag
046 implements ButtonTagDeclaration {
047
048 private static final Log LOG = LogFactory.getLog(ButtonTag.class);
049
050 private String label;
051 private String image;
052 private String tip;
053 private String defaultCommand;
054 private String target;
055 private String markup;
056 private String tabIndex;
057
058 @Override
059 protected void setProperties(UIComponent component) {
060 super.setProperties(component);
061 ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
062 ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
063 ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
064 ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
065 ComponentUtil.setBooleanProperty(component, ATTR_DEFAULT_COMMAND, defaultCommand);
066 ComponentUtil.setMarkup(component, markup);
067 ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
068 }
069
070 public String getComponentType() {
071 return UIButtonCommand.COMPONENT_TYPE;
072 }
073
074 @Override
075 public void release() {
076 super.release();
077 label = null;
078 image = null;
079 tip = null;
080 defaultCommand = null;
081 target = null;
082 markup = null;
083 tabIndex = null;
084 }
085
086 public String getAccessKey() {
087 return null;
088 }
089
090 public void setAccessKey(String accessKey) {
091 if (Deprecation.LOG.isErrorEnabled()) {
092 Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
093 + "and will removed soon! Please use special syntax of 'label' instead.");
094 }
095 }
096
097 public String getImage() {
098 return image;
099 }
100
101 public void setImage(String image) {
102 this.image = image;
103 }
104
105 @Override
106 public String getLabel() {
107 return label;
108 }
109
110 @Override
111 public void setLabel(String label) {
112 this.label = label;
113 }
114
115 public String getLabelWithAccessKey() {
116 return null;
117 }
118
119 public void setLabelWithAccessKey(String labelWithAccessKey) {
120 if (Deprecation.LOG.isWarnEnabled()) {
121 Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
122 + "and will removed soon! Please use 'label' instead.");
123 }
124 setLabel(labelWithAccessKey);
125 }
126
127 public void setTip(String tip) {
128 this.tip = tip;
129 }
130
131 public void setDefaultCommand(String defaultCommand) {
132 this.defaultCommand = defaultCommand;
133 }
134
135 public void setTarget(String target) {
136 this.target = target;
137 }
138
139 public void setMarkup(String markup) {
140 this.markup = markup;
141 }
142
143 public void setTabIndex(String tabIndex) {
144 this.tabIndex = tabIndex;
145 }
146 }
147