View Javadoc
1 package com.gotjava.web.taglibs.calendar; 2 3 import com.gotjava.model.calendar.CalendarSpan; 4 5 import javax.servlet.jsp.tagext.BodyTagSupport; 6 import javax.servlet.jsp.tagext.BodyContent; 7 import javax.servlet.jsp.JspWriter; 8 import javax.servlet.jsp.JspTagException; 9 import java.util.GregorianCalendar; 10 import java.util.Calendar; 11 import java.io.IOException; 12 13 /*** 14 * <p>Description: </p> 15 * <p>Created: Mar 15, 2003</p> 16 * @author farra 17 */ 18 public class DaysOfWeekTag extends BodyTagSupport { 19 20 private int m_counter = 0; 21 private Calendar m_cal; 22 23 public int doStartTag() throws JspTagException { 24 25 m_counter = 0; 26 27 if(m_counter < 7 ){ 28 CalendarSpan span = (CalendarSpan) pageContext.getAttribute("currentSpan"); 29 30 GregorianCalendar cal = new GregorianCalendar(); 31 cal.setTime(span.getStartDate()); 32 33 int week = cal.getActualMinimum(Calendar.DAY_OF_WEEK); 34 cal.set(Calendar.DAY_OF_WEEK, week); 35 m_cal = cal; 36 37 m_cal.add(Calendar.DAY_OF_WEEK,0); 38 pageContext.setAttribute("currentDate",m_cal.getTime()); 39 m_counter++; 40 41 42 return EVAL_BODY_BUFFERED; 43 } 44 else{ 45 return SKIP_BODY; 46 } 47 48 } 49 50 51 public int doAfterBody() 52 { 53 try 54 { 55 BodyContent body = getBodyContent(); 56 JspWriter out = body.getEnclosingWriter(); 57 out.println(body.getString()); 58 body.clearBody(); 59 } 60 catch (IOException ex) 61 { 62 } 63 if (m_counter < 7) 64 { 65 m_cal.add(Calendar.DAY_OF_WEEK,1); 66 pageContext.setAttribute("currentDate",m_cal.getTime()); 67 m_counter++; 68 return EVAL_BODY_BUFFERED; 69 } 70 else 71 return SKIP_BODY; 72 } 73 74 }

This page was automatically generated by Maven