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