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