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_DISABLED;
023    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
024    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
025    import org.apache.myfaces.tobago.component.ComponentUtil;
026    import org.apache.myfaces.tobago.component.UITab;
027    import org.apache.myfaces.tobago.util.Deprecation;
028    
029    import javax.faces.component.UIComponent;
030    import javax.servlet.jsp.tagext.BodyTag;
031    
032    // Some Weblogic versions need explicit 'implements' for BodyTag
033    public class TabTag extends TobagoBodyTag
034        implements BodyTag, TabTagDeclaration {
035    
036      private static final Log LOG = LogFactory.getLog(TabTag.class);
037    
038      private String label;
039      private String tip;
040      private String markup;
041      private String disabled;
042    
043      public String getComponentType() {
044        return UITab.COMPONENT_TYPE;
045      }
046    
047      protected void setProperties(UIComponent component) {
048        super.setProperties(component);
049        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
050        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
051        ComponentUtil.setMarkup(component, markup);
052        ComponentUtil.setBooleanProperty(component, ATTR_DISABLED, disabled);
053      }
054    
055      public void release() {
056        super.release();
057        label = null;
058        tip = null;
059        markup = null;
060        disabled = null;
061      }
062    
063      public void setMarkup(String markup) {
064        this.markup = markup;
065      }
066    
067      public String getLabel() {
068        return label;
069      }
070    
071      public void setLabel(String label) {
072        this.label = label;
073      }
074    
075      public String getAccessKey() {
076        return null;
077      }
078    
079      public void setAccessKey(String accessKey) {
080        if (Deprecation.LOG.isErrorEnabled()) {
081          Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
082              + "and will removed soon! Please use special syntax of 'label' instead.");
083        }
084      }
085    
086      public String getLabelWithAccessKey() {
087        return label;
088      }
089    
090      public void setLabelWithAccessKey(String labelWithAccessKey) {
091        if (Deprecation.LOG.isWarnEnabled()) {
092          Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
093              + "and will removed soon! Please use 'label' instead.");
094        }
095        setLabel(labelWithAccessKey);
096      }
097    
098      public String getTip() {
099        return tip;
100      }
101    
102      public void setTip(String tip) {
103        this.tip = tip;
104      }
105    
106      public String getDisabled() {
107        return disabled;
108      }
109    
110      public void setDisabled(String disabled) {
111        this.disabled = disabled;
112      }
113    }
114