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