1 18 package org.apache.roller.ui.core.tags; 19 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.jsp.tagext.TagSupport ; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.apache.struts.Globals; 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.util.RequestUtils; 28 29 33 public class DateTag extends TagSupport { 34 static final long serialVersionUID = 1485100916981692535L; 35 36 public static final String KEY_PREFIX = "ZZZ_DATETAG_ZZZ"; 38 39 private String property = null; 40 private String dateFormat = null; 41 private Boolean readOnly = Boolean.FALSE; 42 private String formName = null; 43 44 private static Log mLogger = 45 LogFactory.getFactory().getInstance(DateTag.class); 46 47 50 public int doStartTag() throws JspException { 51 52 ActionMapping mapping = 54 (ActionMapping) pageContext.getRequest().getAttribute( 55 Globals.MAPPING_KEY); 56 if (formName == null) { 57 formName = mapping.getName(); 58 } 59 60 Object value = 62 RequestUtils.lookup(pageContext, formName, property, null); 63 if (value == null) 64 value = ""; 65 66 pageContext.getRequest().setAttribute( 68 KEY_PREFIX + "_formName", 69 formName); 70 pageContext.getRequest().setAttribute( 71 KEY_PREFIX + "_property", 72 property); 73 pageContext.getRequest().setAttribute( 74 KEY_PREFIX + "_dateFormat", 75 dateFormat); 76 pageContext.getRequest().setAttribute( 77 KEY_PREFIX + "_readOnly", 78 readOnly); 79 pageContext.getRequest().setAttribute(KEY_PREFIX + "_value", value); 80 81 try { 83 pageContext.include("/roller-ui/widgets/date.jsp"); 84 } catch (Exception e) { 85 throw new JspException ("ERROR including date.jsp"); 87 } 88 89 return (SKIP_BODY); 91 } 92 93 98 public String getDateFormat() { 99 return dateFormat; 100 } 101 102 public void setDateFormat(String dateFormat) { 103 this.dateFormat = dateFormat; 104 } 105 106 110 public String getProperty() { 111 return property; 112 } 113 114 public void setProperty(String property) { 115 this.property = property; 116 } 117 118 122 public Boolean getReadOnly() { 123 return readOnly; 124 } 125 126 public void setReadOnly(Boolean readOnly) { 127 this.readOnly = readOnly; 128 } 129 130 134 public String getFormName() { 135 return formName; 136 } 137 138 public void setFormName(String formName) { 139 this.formName = formName; 140 } 141 142 } 143 | Popular Tags |