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