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_IMAGE;
025    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
026    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
027    import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUCOMMAND;
028    import org.apache.myfaces.tobago.component.ComponentUtil;
029    import org.apache.myfaces.tobago.component.UIMenuCommand;
030    import org.apache.myfaces.tobago.util.Deprecation;
031    
032    import javax.faces.component.UIComponent;
033    
034    
035    public class MenuCommandTag extends AbstractCommandTag
036        implements MenuCommandTagDeclaration {
037      private static final Log LOG = LogFactory.getLog(MenuCommandTag.class);
038    
039      //public static final String COMMAND_TYPE = "menuCommand";
040    
041      private String image;
042      private String label;
043      private String target;
044    
045      public String getComponentType() {
046        return UIMenuCommand.COMPONENT_TYPE;
047      }
048    
049      public void release() {
050        super.release();
051        image = null;
052        label = null;
053        target = null;
054      }
055    
056      protected void setProperties(UIComponent component) {
057        super.setProperties(component);
058        component.setRendererType(RENDERER_TYPE_MENUCOMMAND);
059        ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
060        //ComponentUtil.setStringProperty(component, ATTR_COMMAND_TYPE, COMMAND_TYPE);
061        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
062        ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
063      }
064    
065      public String getImage() {
066        return image;
067      }
068    
069      public void setImage(String image) {
070        this.image = image;
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 void setTarget(String target) {
101        this.target = target;
102      }
103    }