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 org.apache.myfaces.tobago.component.ComponentUtil;
027 import org.apache.myfaces.tobago.component.UIMenu;
028 import org.apache.myfaces.tobago.util.Deprecation;
029
030 import javax.faces.component.UIComponent;
031
032
033 public class MenuTag extends TobagoTag
034 implements MenuTagDeclaration {
035
036 private static final Log LOG = LogFactory.getLog(MenuTag.class);
037
038 //public static final String MENU_TYPE = "menu";
039
040 private String label;
041 private String image;
042 // private String disabled;
043
044 protected void setProperties(UIComponent component) {
045 super.setProperties(component);
046 component.setRendererType(null);
047 ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
048 ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
049 //ComponentUtil.setStringProperty(component, ATTR_COMMAND_TYPE, "menu");
050 }
051
052 public String getComponentType() {
053 return UIMenu.COMPONENT_TYPE;
054 }
055
056
057 public void release() {
058 super.release();
059 label = null;
060 image = null;
061 }
062
063 public String getLabel() {
064 return label;
065 }
066
067 public void setLabel(String label) {
068 this.label = label;
069 }
070
071 public String getImage() {
072 return image;
073 }
074
075 public void setImage(String image) {
076 this.image = image;
077 }
078
079 public String getAccessKey() {
080 return null;
081 }
082
083 public void setAccessKey(String accessKey) {
084 if (Deprecation.LOG.isErrorEnabled()) {
085 Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
086 + "and will removed soon! Please use special syntax of 'label' instead.");
087 }
088 }
089
090 public String getLabelWithAccessKey() {
091 return null;
092 }
093
094 public void setLabelWithAccessKey(String labelWithAccessKey) {
095 if (Deprecation.LOG.isWarnEnabled()) {
096 Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
097 + "and will removed soon! Please use 'label' instead.");
098 }
099 setLabel(labelWithAccessKey);
100 }
101 }