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_DISABLED;
025    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
026    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
027    import org.apache.myfaces.tobago.component.ComponentUtil;
028    import org.apache.myfaces.tobago.component.UITab;
029    import org.apache.myfaces.tobago.util.Deprecation;
030    
031    import javax.faces.component.UIComponent;
032    import javax.servlet.jsp.tagext.BodyTag;
033    
034    // Some Weblogic versions need explicit 'implements' for BodyTag
035    public class TabTag extends TobagoBodyTag
036        implements BodyTag, TabTagDeclaration {
037    
038      private static final Log LOG = LogFactory.getLog(TabTag.class);
039    
040      private String label;
041      private String tip;
042      private String markup;
043      private String disabled;
044    
045      public String getComponentType() {
046        return UITab.COMPONENT_TYPE;
047      }
048    
049      protected void setProperties(UIComponent component) {
050        super.setProperties(component);
051        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
052        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
053        ComponentUtil.setMarkup(component, markup);
054        ComponentUtil.setBooleanProperty(component, ATTR_DISABLED, disabled);
055      }
056    
057      public void release() {
058        super.release();
059        label = null;
060        tip = null;
061        markup = null;
062        disabled = null;
063      }
064    
065      public void setMarkup(String markup) {
066        this.markup = markup;
067      }
068    
069      public String getLabel() {
070        return label;
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 label;
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    
108      public String getDisabled() {
109        return disabled;
110      }
111    
112      public void setDisabled(String disabled) {
113        this.disabled = disabled;
114      }
115    }
116