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_LABEL;
023    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
024    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
025    import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUCOMMAND;
026    import org.apache.myfaces.tobago.component.ComponentUtil;
027    import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
028    import org.apache.myfaces.tobago.util.Deprecation;
029    
030    import javax.faces.component.UIComponent;
031    
032    /**
033     * User: weber
034     * Date: Apr 26, 2005
035     * Time: 3:01:45 PM
036     */
037    public class SelectBooleanCommandTag extends AbstractCommandTag {
038    
039      private static final Log LOG = LogFactory.getLog(SelectBooleanCommandTag.class);
040    
041      private String label;
042      private String value;
043      private String tip;
044    
045    
046      public String getComponentType() {
047        return UISelectBooleanCommand.COMPONENT_TYPE;
048      }
049    
050      protected void setProperties(UIComponent component) {
051        super.setProperties(component);
052        component.setRendererType(RENDERER_TYPE_MENUCOMMAND);
053        ComponentUtil.setStringProperty(component, ATTR_VALUE, value);
054        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
055        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
056      }
057    
058      public void release() {
059        super.release();
060        value = null;
061        label = null;
062        tip = null;
063      }
064    
065      public String getValue() {
066        return value;
067      }
068    
069      public void setValue(String value) {
070        this.value = value;
071      }
072    
073      public void setLabel(String label) {
074        this.label = label;
075      }
076    
077      public String getAccessKey() {
078        return null;
079      }
080    
081      public void setAccessKey(String accessKey) {
082        if (Deprecation.LOG.isErrorEnabled()) {
083          Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
084              + "and will removed soon! Please use special syntax of 'label' instead.");
085        }
086      }
087    
088      public String getLabelWithAccessKey() {
089        return null;
090      }
091    
092      public void setLabelWithAccessKey(String labelWithAccessKey) {
093        if (Deprecation.LOG.isWarnEnabled()) {
094          Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
095              + "and will removed soon! Please use 'label' instead.");
096        }
097        setLabel(labelWithAccessKey);
098      }
099    
100      public String getTip() {
101        return tip;
102      }
103    
104      public void setTip(String tip) {
105        this.tip = tip;
106      }
107    }