1 16 package dlog4j.tags; 17 18 import java.io.IOException ; 19 import java.util.Calendar ; 20 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.tagext.TagSupport ; 23 24 import dlog4j.util.StringUtils; 25 26 30 public class CalendarCellColorTag extends TagSupport { 31 32 protected String yearId = "year"; 33 protected String monthId = "month"; 34 protected String color=null; 35 protected int day; 36 37 private boolean isToday = false; 38 39 42 public int doStartTag() throws JspException { 43 Calendar cal = Calendar.getInstance(); 44 int year = ((Integer )pageContext.getAttribute(yearId)).intValue(); 45 int month = ((Integer )pageContext.getAttribute(monthId)).intValue()-1; 46 isToday = cal.get(Calendar.YEAR)==year && cal.get(Calendar.MONTH)==month && cal.get(Calendar.DATE)==day; 47 try{ 48 if(isToday){ 49 if(StringUtils.isNotEmpty(color)){ 50 pageContext.getOut().print("<font color='"); 51 pageContext.getOut().print(color); 52 pageContext.getOut().print("'>"); 53 } 54 pageContext.getOut().print("<b>"); 55 } 56 }catch(IOException e){} 57 return EVAL_BODY_INCLUDE; 58 } 59 60 public int doEndTag() throws JspException { 61 try{ 62 if(isToday){ 63 pageContext.getOut().print("</b>"); 64 if(StringUtils.isNotEmpty(color)){ 65 pageContext.getOut().print("</font>"); 66 } 67 } 68 }catch(Exception e){} 69 return EVAL_PAGE; 70 } 71 74 public String getMonthId() { 75 return monthId; 76 } 77 78 81 public String getYearId() { 82 return yearId; 83 } 84 85 88 public void setMonthId(String string) { 89 monthId = string; 90 } 91 92 95 public void setYearId(String string) { 96 yearId = string; 97 } 98 99 102 public String getColor() { 103 return color; 104 } 105 106 109 public void setColor(String string) { 110 color = string; 111 } 112 113 116 public Object getDay() { 117 return new Integer (day); 118 } 119 120 123 public void setDay(Object i) { 124 if(i==null) 125 return; 126 if(i instanceof Integer ) 127 day = ((Integer )i).intValue(); 128 else if(i instanceof String ) 129 day = Integer.parseInt((String )i); 130 } 131 132 } 133 | Popular Tags |