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