1 18 package org.apache.beehive.netui.tags.databinding.repeater.pad; 19 20 import javax.servlet.jsp.JspException ; 21 22 import org.apache.beehive.netui.tags.databinding.repeater.RepeaterComponent; 23 import org.apache.beehive.netui.util.Bundle; 24 import org.apache.beehive.netui.util.logging.Logger; 25 26 95 public class Pad 96 extends RepeaterComponent { 97 98 private static final Logger LOGGER = Logger.getInstance(Pad.class); 99 100 private String _padText = null; 101 private Integer _maxRepeat = null; 102 private Integer _minRepeat = null; 103 104 110 public String getTagName() { 111 return "Pad"; 112 } 113 114 125 public void setPadText(String padText) { 126 _padText = padText; 127 } 128 129 142 public void setMaxRepeat(int maxRepeat) { 143 _maxRepeat = new Integer (maxRepeat); 144 } 145 146 156 public void setMinRepeat(int minRepeat) { 157 _minRepeat = new Integer (minRepeat); 158 } 159 160 protected boolean shouldRender() { 161 if(_padText == null) 162 return true; 163 else 164 return false; 165 } 166 167 public int doAfterBody() 168 throws JspException { 169 return SKIP_BODY; 170 } 171 172 180 protected int renderEndTag(int state) 181 throws JspException { 182 183 if(_padText == null && bodyContent != null) { 184 _padText = bodyContent.getString(); 185 } 186 187 if(hasErrors()) { 188 reportErrors(); 189 localRelease(); 190 return EVAL_PAGE; 191 } 192 193 PadContext pc = new PadContext(_padText, 194 (_minRepeat != null ? _minRepeat.intValue() : PadContext.DEFAULT_VALUE), 195 (_maxRepeat != null ? _maxRepeat.intValue() : PadContext.DEFAULT_VALUE)); 196 197 getRepeater().setPadContext(pc); 198 199 return EVAL_PAGE; 200 } 201 202 205 protected void localRelease() { 206 super.localRelease(); 207 if(bodyContent != null) 208 bodyContent.clearBody(); 209 _padText = null; 210 _maxRepeat = null; 211 _minRepeat = null; 212 } 213 214 224 protected void verifyAttributes() 225 throws JspException { 226 if(_maxRepeat != null && _maxRepeat.intValue() <= 0) { 227 String msg = Bundle.getErrorString("Tags_Pad_intTooSmall", new Object []{_maxRepeat, "maxRepeat"}); 228 getRepeater().registerTagError(msg, null); 229 } 230 231 if(_minRepeat != null && _minRepeat.intValue() <= 0) { 232 String msg = Bundle.getErrorString("Tags_Pad_minRepeatIntTooSmall", new Object []{_minRepeat, "minRepeat"}); 233 getRepeater().registerTagError(msg, null); 234 } 235 236 if(_maxRepeat != null && 238 _minRepeat != null && 239 _minRepeat.intValue() > _maxRepeat.intValue()) { 240 if(LOGGER.isWarnEnabled()) { 241 String msg = "The value of maxRepeat (" + _maxRepeat + ") must be greater than the value of minRepeat (" + 242 _minRepeat + ") on the Repeater Pad tag."; 243 LOGGER.warn(msg); 244 } 245 246 String msg = Bundle.getErrorString("Tags_Pad_minGreaterThanMax", new Object []{_maxRepeat, _minRepeat}); 247 getRepeater().registerTagError(msg, null); 248 } 249 } 250 } 251 252 | Popular Tags |