1 25 29 package org.jresearch.gossip.tags; 30 31 import java.util.ArrayList ; 32 33 import javax.servlet.jsp.JspException ; 34 import javax.servlet.jsp.tagext.TagSupport ; 35 36 41 public class NumericOptionsTag extends TagSupport { 42 private int startValue; 43 44 private int endValue; 45 46 private int step = 1; 47 48 56 public int doStartTag() throws JspException { 57 try { 58 ArrayList options = new ArrayList (); 59 60 if (startValue < endValue) { 61 while (startValue <= endValue) { 62 OptionBean option = new OptionBean(); 63 option.setLabelProperty(startValue + ""); 64 option.setProperty(startValue + ""); 65 options.add(option); 66 startValue += step; 67 } 68 } else { 69 while (startValue >= endValue) { 70 OptionBean option = new OptionBean(); 71 option.setLabelProperty(startValue + ""); 72 option.setProperty(startValue + ""); 73 options.add(option); 74 startValue -= step; 75 } 76 } 77 78 pageContext.setAttribute("NumericOptions", options); 79 } catch (Exception ex) { 80 throw new JspException ("error in NumericOptionsTag tag:", ex); 81 } 82 83 return (SKIP_BODY); 84 } 85 86 91 public void setEndValue(int i) { 92 endValue = i; 93 } 94 95 100 public void setStartValue(int i) { 101 startValue = i; 102 } 103 104 109 public void setStep(int i) { 110 step = i; 111 } 112 } 113 | Popular Tags |