1 package org.roller.presentation.tags; 2 3 import javax.servlet.jsp.JspException ; 4 import javax.servlet.jsp.tagext.TagSupport ; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.apache.struts.Globals; 9 import org.apache.struts.action.ActionMapping; 10 import org.apache.struts.util.RequestUtils; 11 12 16 public class DateTag extends TagSupport 17 { 18 static final long serialVersionUID = 1485100916981692535L; 19 20 public static final String KEY_PREFIX = "ZZZ_DATETAG_ZZZ"; 22 23 private String property = null; 24 private String dateFormat = null; 25 private Boolean readOnly = Boolean.FALSE; 26 27 private static Log mLogger = 28 LogFactory.getFactory().getInstance(DateTag.class); 29 30 33 public int doStartTag() throws JspException 34 { 35 36 ActionMapping mapping = 38 (ActionMapping) pageContext.getRequest().getAttribute( 39 Globals.MAPPING_KEY); 40 String formName = mapping.getName(); 41 42 Object value = 44 RequestUtils.lookup(pageContext, formName, property, null); 45 if (value == null) 46 value = ""; 47 48 pageContext.getRequest().setAttribute( 50 KEY_PREFIX + "_formName", 51 formName); 52 pageContext.getRequest().setAttribute( 53 KEY_PREFIX + "_property", 54 property); 55 pageContext.getRequest().setAttribute( 56 KEY_PREFIX + "_dateFormat", 57 dateFormat); 58 pageContext.getRequest().setAttribute( 59 KEY_PREFIX + "_readOnly", 60 readOnly); 61 pageContext.getRequest().setAttribute(KEY_PREFIX + "_value", value); 62 63 try 65 { 66 pageContext.include("/tags/date.jsp"); 67 } 68 catch (Exception e) 69 { 70 throw new JspException ("ERROR including date.jsp"); 72 } 73 74 return (SKIP_BODY); 76 } 77 78 83 public String getDateFormat() 84 { 85 return dateFormat; 86 } 87 88 92 public String getProperty() 93 { 94 return property; 95 } 96 97 101 public Boolean getReadOnly() 102 { 103 return readOnly; 104 } 105 106 public void setDateFormat(String dateFormat) 107 { 108 this.dateFormat = dateFormat; 109 } 110 111 public void setProperty(String property) 112 { 113 this.property = property; 114 } 115 116 public void setReadOnly(Boolean readOnly) 117 { 118 this.readOnly = readOnly; 119 } 120 121 } 122 | Popular Tags |