View Javadoc
1 package com.mlw.fps.view.taglib; 2 3 import javax.servlet.jsp.JspException; 4 5 import org.apache.struts.util.ResponseUtils; 6 7 public class CalendarTag extends org.apache.struts.taglib.html.BaseFieldTag 8 { 9 10 /*** Holds value of property calendar icon. */ 11 private String icon; 12 13 public CalendarTag() 14 { 15 super(); 16 this.type = "text"; 17 } 18 19 /*** Generate the required calendar tag. 20 * 21 * @exception JspException if a JSP exception has occurred 22 * @return */ 23 public int doStartTag() throws JspException 24 { 25 ResponseUtils.write(pageContext, "<table border=\"0\"><tr><td>" ); 26 27 int returnValue = super.doStartTag(); 28 29 ResponseUtils.write(pageContext, "</td><td>" ); 30 31 //Write the image that is clicked to bring up the calendar. 32 StringBuffer image = new StringBuffer(); 33 image.append("<img"); 34 image.append(" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" src=\"").append(getIcon()).append("\" "); 35 image.append(" onclick=\"javascript:showCalendar(this, '").append(getStyleId()).append("Click', document.getElementById('").append(getStyleId()).append("').value)\">"); 36 ResponseUtils.write(pageContext, image.toString()); 37 38 ResponseUtils.write(pageContext, "</td></tr></table>"); 39 40 //Write the function that is called when the calendar is clicked. 41 //This currently only supports "mm/dd/yyyy"! 42 StringBuffer script = new StringBuffer(); 43 script.append("<script>\n"); 44 script.append(" function ").append(getStyleId()).append("Click(month, day, year)\n"); 45 script.append(" {\n"); 46 script.append(" document.getElementById('").append(getStyleId()).append("').value=month+'/'+day+'/'+year;\n"); 47 script.append(" hideCalendar();\n"); 48 script.append(" }\n"); 49 script.append("</script>\n"); 50 ResponseUtils.write(pageContext, script.toString()); 51 52 return (returnValue); 53 } 54 55 /*** Getter for property icon. 56 * @return Value of property icon. 57 */ 58 public String getIcon() 59 { 60 return this.icon; 61 } 62 63 /*** Setter for property icon. 64 * @param icon New value of property icon. 65 */ 66 public void setIcon(String icon) 67 { 68 this.icon = icon; 69 } 70 71 }

This page was automatically generated by Maven