| 1 package fr.improve.struts.taglib.layout.field; 2 3 import javax.servlet.jsp.JspException ; 4 5 import org.apache.struts.taglib.html.BaseHandlerTag; 6 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 import fr.improve.struts.taglib.layout.util.TagUtils; 9 14 public class FileTag extends AbstractFieldTag { 15 protected String fileName; 16 protected String fileKey; 17 protected String filePath; 18 protected String target; 19 20 protected boolean doBeforeValue() throws JspException { 21 StringBuffer buffer = new StringBuffer (); 22 if (filePath!=null) { 23 buffer.append("<a HREF=\""); 25 Object lc_url = LayoutUtils.getBeanFromPageContext(pageContext, name, filePath); 26 buffer.append(LayoutUtils.computeURL(pageContext, null, lc_url==null ? "" : lc_url.toString(), null, null, null, null, null, false, target)); 27 buffer.append("\" class=\""); 28 buffer.append(styleClass); 29 if (target!=null) { 30 buffer.append("\" target=\""); 31 buffer.append(target); 32 } 33 buffer.append("\">"); 34 if (fileName != null) 35 buffer.append(LayoutUtils.getBeanFromPageContext(pageContext, name, fileName)); 36 else 37 buffer.append(LayoutUtils.getLabel(pageContext, fileKey, null)); 38 buffer.append("</a>"); 39 } 40 value = null; 41 42 switch (getFieldDisplayMode()) { 43 case MODE_EDIT : 44 if (filePath!=null) { 45 buffer.append("<br>"); 46 } 47 TagUtils.write(pageContext, buffer.toString()); 48 break; 49 case MODE_INSPECT : 50 TagUtils.write(pageContext, buffer.toString()); 51 return false; 52 } 53 54 fieldTag = new org.apache.struts.taglib.html.FileTag(); 56 return true; 57 } 58 61 protected Object getFieldValue() throws JspException { 62 return fileName; 63 } 64 69 java.lang.String getFileKey() { 70 return fileKey; 71 } 72 77 java.lang.String getFileName() { 78 return fileName; 79 } 80 85 java.lang.String getFilePath() { 86 return filePath; 87 } 88 public void release() { 89 super.release(); 90 fileName = null; 91 fileKey = null; 92 filePath = null; 93 target = null; 94 } 95 100 public void setFileKey(java.lang.String newFileKey) { 101 fileKey = newFileKey; 102 } 103 108 public void setFileName(java.lang.String newFileName) { 109 fileName = newFileName; 110 } 111 116 public void setFilePath(java.lang.String newFilePath) { 117 filePath = newFilePath; 118 } 119 123 public String getTarget() { 124 return target; 125 } 126 127 131 public void setTarget(String target) { 132 this.target = target; 133 } 134 135 protected void copyProperties(BaseHandlerTag in_dest) throws JspException { 136 super.copyProperties(in_dest); 137 org.apache.struts.taglib.html.FileTag tag = (org.apache.struts.taglib.html.FileTag) in_dest; 138 tag.setAccept(getAccept()); 139 tag.setName(getName()); 140 141 tag.setCols(getCols()); 142 tag.setMaxlength(getMaxlength()); 143 tag.setProperty(getProperty()); 144 tag.setRows(getRows()); 145 tag.setValue(getValue()); 146 147 } 148 149 } 150 | Popular Tags |