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_FOCUS;
023 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ONCHANGE;
024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
026 import org.apache.myfaces.tobago.component.ComponentUtil;
027 import org.apache.myfaces.tobago.util.Deprecation;
028
029 import javax.faces.component.EditableValueHolder;
030 import javax.faces.component.UIComponent;
031
032 public abstract class InputTag extends BeanTag implements InputTagDeclaration {
033 private static final Log LOG = LogFactory.getLog(InputTag.class);
034
035 private String onchange;
036 private String focus;
037 private String tip;
038 private String validator;
039 private String valueChangeListener;
040 private String tabIndex;
041
042 public void release() {
043 super.release();
044 this.onchange = null;
045 this.focus = null;
046 tip = null;
047 validator = null;
048 valueChangeListener = null;
049 tabIndex = null;
050 }
051
052 protected void setProperties(UIComponent component) {
053 super.setProperties(component);
054 ComponentUtil.setStringProperty(component, ATTR_ONCHANGE, onchange);
055 ComponentUtil.setBooleanProperty(component, ATTR_FOCUS, focus);
056 ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
057 ComponentUtil.setIntegerProperty(component, ATTR_TAB_INDEX, tabIndex);
058 if (component instanceof EditableValueHolder) {
059 EditableValueHolder editableValueHolder = (EditableValueHolder) component;
060 ComponentUtil.setValidator(editableValueHolder, validator);
061 ComponentUtil.setValueChangeListener(editableValueHolder, valueChangeListener);
062 }
063 }
064
065 public String getOnchange() {
066 return onchange;
067 }
068
069 public void setOnchange(String onchange) {
070 this.onchange = onchange;
071 }
072
073 public String getFocus() {
074 return focus;
075 }
076
077 public void setFocus(String focus) {
078 this.focus = focus;
079 }
080
081 public String getAccessKey() {
082 return null;
083 }
084
085 public void setAccessKey(String accessKey) {
086 if (Deprecation.LOG.isErrorEnabled()) {
087 Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
088 + "and will removed soon! Please use special syntax of 'label' instead.");
089 }
090 }
091
092 public String getLabelWithAccessKey() {
093 return null;
094 }
095
096 public void setLabelWithAccessKey(String labelWithAccessKey) {
097 if (Deprecation.LOG.isWarnEnabled()) {
098 Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
099 + "and will removed soon! Please use 'label' instead.");
100 }
101 setLabel(labelWithAccessKey);
102 }
103
104 public String getTip() {
105 return tip;
106 }
107
108 public void setTip(String tip) {
109 this.tip = tip;
110 }
111
112 public String getValidator() {
113 return validator;
114 }
115
116 public void setValidator(String validator) {
117 this.validator = validator;
118 }
119
120 public String getValueChangeListener() {
121 return valueChangeListener;
122 }
123
124 public void setValueChangeListener(String valueChangeListener) {
125 this.valueChangeListener = valueChangeListener;
126 }
127
128 public String getTabIndex() {
129 return tabIndex;
130 }
131
132 public void setTabIndex(String tabIndex) {
133 this.tabIndex = tabIndex;
134 }
135 }
136