001/* 002 * Copyright 2008 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.sys.document.web; 017 018import javax.servlet.jsp.JspException; 019import javax.servlet.jsp.PageContext; 020import javax.servlet.jsp.tagext.Tag; 021 022import org.apache.commons.lang.StringUtils; 023import org.kuali.ole.sys.document.web.renderers.LabelRenderer; 024 025/** 026 * A class which represents a renderable header label for an input 027 */ 028public class FieldHeaderLabel extends HeaderLabel { 029 private HeaderLabelPopulating headerLabelPopulator; 030 private String label; 031 private boolean readOnly = false; 032 private boolean required = false; 033 private String labelFor; 034 private String fullClassNameForHelp; 035 private String attributeEntryForHelp; 036 037 /** 038 * Constructs a FieldHeaderLabel, forcing an implementation of HeaderLabelPopulating to be passed in 039 * @param headerLabelPopulator the populator who will populate this label when the time has come 040 */ 041 public FieldHeaderLabel(HeaderLabelPopulating headerLabelPopulator) { 042 this.headerLabelPopulator = headerLabelPopulator; 043 } 044 045 /** 046 * Gets the attributeEntryForHelp attribute. 047 * @return Returns the attributeEntryForHelp. 048 */ 049 public String getAttributeEntryForHelp() { 050 return attributeEntryForHelp; 051 } 052 053 /** 054 * Sets the attributeEntryForHelp attribute value. 055 * @param attributeEntryForHelp The attributeEntryForHelp to set. 056 */ 057 public void setAttributeEntryForHelp(String attributeEntryForHelp) { 058 this.attributeEntryForHelp = attributeEntryForHelp; 059 } 060 061 /** 062 * Gets the fullClassNameForHelp attribute. 063 * @return Returns the fullClassNameForHelp. 064 */ 065 public String getFullClassNameForHelp() { 066 return fullClassNameForHelp; 067 } 068 069 /** 070 * Sets the fullClassNameForHelp attribute value. 071 * @param fullClassNameForHelp The fullClassNameForHelp to set. 072 */ 073 public void setFullClassNameForHelp(String fullClassNameForHelp) { 074 this.fullClassNameForHelp = fullClassNameForHelp; 075 } 076 077 /** 078 * Gets the label attribute. 079 * @return Returns the label. 080 */ 081 public String getLabel() { 082 return label; 083 } 084 085 /** 086 * Sets the label attribute value. 087 * @param label The label to set. 088 */ 089 public void setLabel(String label) { 090 this.label = label; 091 } 092 093 /** 094 * Gets the labelFor attribute. 095 * @return Returns the labelFor. 096 */ 097 public String getLabelFor() { 098 return labelFor; 099 } 100 101 /** 102 * Sets the labelFor attribute value. 103 * @param labelFor The labelFor to set. 104 */ 105 public void setLabelFor(String labelFor) { 106 this.labelFor = labelFor; 107 } 108 109 /** 110 * Gets the readOnly attribute. 111 * @return Returns the readOnly. 112 */ 113 public boolean isReadOnly() { 114 return readOnly; 115 } 116 117 /** 118 * Sets the readOnly attribute value. 119 * @param readOnly The readOnly to set. 120 */ 121 public void setReadOnly(boolean readOnly) { 122 this.readOnly = readOnly; 123 } 124 125 /** 126 * Gets the required attribute. 127 * @return Returns the required. 128 */ 129 public boolean isRequired() { 130 return required; 131 } 132 133 /** 134 * Sets the required attribute value. 135 * @param required The required to set. 136 */ 137 public void setRequired(boolean required) { 138 this.required = required; 139 } 140 141 /** 142 * @see org.kuali.ole.sys.document.web.RenderableElement#renderElement(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.ole.sys.document.web.AccountingLineRenderingContext) 143 */ 144 public void renderElement(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException { 145 headerLabelPopulator.populateHeaderLabel(this, renderingContext); 146 LabelRenderer renderer = new LabelRenderer(); 147 renderer.setLabel(label); 148 renderer.setRequired(required); 149 renderer.setReadOnly(readOnly); 150 renderer.setLabelFor(labelFor); 151 if (!StringUtils.isBlank(fullClassNameForHelp)) { 152 renderer.setFullClassNameForHelp(fullClassNameForHelp); 153 } 154 if (!StringUtils.isBlank(attributeEntryForHelp)) { 155 renderer.setAttributeEntryForHelp(attributeEntryForHelp); 156 } 157 renderer.render(pageContext, parentTag); 158 renderer.clear(); 159 } 160 161}