1 23 24 package org.dbforms.taglib; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.jsp.JspException ; 28 29 30 31 40 public class DbDateFieldTag extends DbBaseInputTag 41 implements javax.servlet.jsp.tagext.TryCatchFinally { 42 43 private String jsCalendarDateFormat; 44 45 46 private String useJsCalendar; 47 48 53 public void setJsCalendarDateFormat(String jsCalendarDateFormat) { 54 this.jsCalendarDateFormat = jsCalendarDateFormat; 55 } 56 57 58 63 public String getJsCalendarDateFormat() { 64 return jsCalendarDateFormat; 65 } 66 67 68 73 public void setUseJsCalendar(String useJsCalendar) { 74 this.useJsCalendar = useJsCalendar; 75 } 76 77 78 83 public String getUseJsCalendar() { 84 return useJsCalendar; 85 } 86 87 88 91 public void doCatch(Throwable t) throws Throwable { 92 throw t; 93 } 94 95 96 104 public int doEndTag() throws JspException { 105 HttpServletRequest request = (HttpServletRequest ) this.pageContext 106 .getRequest(); 107 108 try { 109 StringBuffer tagBuf = new StringBuffer ("<input "); 110 tagBuf.append(prepareType()); 111 tagBuf.append(prepareName()); 112 tagBuf.append(prepareValue()); 113 tagBuf.append(prepareSize()); 114 tagBuf.append(prepareKeys()); 115 tagBuf.append(prepareStyles()); 116 tagBuf.append(prepareEventHandlers()); 117 tagBuf.append("/>"); 118 119 if (!hasHiddenSet() && ("true".equals(this.getUseJsCalendar()))) { 123 tagBuf.append(" <a HREF=\"javascript:doNothing()\" ") 124 .append(" onclick=\""); 125 126 if ((jsCalendarDateFormat == null) 129 && (getFormatter() instanceof java.text.SimpleDateFormat )) { 130 java.text.SimpleDateFormat mysdf = (java.text.SimpleDateFormat ) getFormatter(); 131 jsCalendarDateFormat = mysdf.toPattern(); 132 133 if (jsCalendarDateFormat.indexOf("dd") >= 0) { 136 jsCalendarDateFormat = jsCalendarDateFormat.replace('d', 'D'); 137 } 138 } 139 140 if (jsCalendarDateFormat != null) { 142 tagBuf.append("calDateFormat='" + jsCalendarDateFormat + "';"); 143 } 144 145 tagBuf.append("setDateField(document.dbform['") 146 .append(getFormFieldName()) 147 .append("']);") 148 .append(" top.newWin = window.open('") 149 .append(request.getContextPath()) 150 .append("/dbformslib/jscal/calendar.html','cal','width=270,height=280')\">") 151 .append("<img SRC=\"") 152 .append(request.getContextPath()) 153 .append("/dbformslib/jscal/calendar.gif\" ") 155 .append(" border=\"0\" alt=\"Click on the Calendar to activate the Pop-Up Calendar Window.\">") 156 .append("</img>") 157 .append("</a>"); 158 } 159 160 getParentForm() 162 .addChildName(getName(), getFormFieldName()); 163 164 pageContext.getOut() 165 .write(tagBuf.toString()); 166 167 writeOutSpecialValues(); 169 } catch (java.io.IOException ioe) { 170 throw new JspException ("IO Error: " + ioe.getMessage()); 171 } 172 173 return EVAL_PAGE; 174 } 175 176 177 180 public void doFinally() { 181 super.doFinally(); 182 } 183 184 185 192 public int doStartTag() throws JspException { 193 super.doStartTag(); 194 195 return SKIP_BODY; 196 } 197 } 198 | Popular Tags |