1 7 package org.jfox.manager.demo; 8 9 import org.jfox.mvc.ActionSupport; 10 import org.jfox.mvc.InvocationContext; 11 import org.jfox.mvc.Invocation; 12 import org.jfox.mvc.FileUploaded; 13 import org.jfox.mvc.PageContext; 14 import org.jfox.mvc.annotation.ActionMethod; 15 import org.jfox.framework.annotation.Service; 16 17 20 @Service(id = "demoupload") 21 public class DemoUploadAction extends ActionSupport { 22 23 @ActionMethod(successView = "demo/upload.vhtml") 24 public void doGetView(InvocationContext invocationContext) throws Exception { 25 } 27 28 @ActionMethod(successView = "demo/upload.vhtml", invocationClass = UploadInvocation.class) 29 public void doPostUpload(InvocationContext invocationContext) throws Exception { 30 UploadInvocation invocation = (UploadInvocation)invocationContext.getInvocation(); 31 FileUploaded uploadFile = invocation.getUploadFile(); 32 String filename = uploadFile.getFilename(); 33 int size = uploadFile.getContent().length; 34 String content = new String (uploadFile.getContent()); 35 content = content.replace("<","<"); 37 38 PageContext pageContext = invocationContext.getPageContext(); 39 pageContext.setAttribute("filename",filename); 40 pageContext.setAttribute("size", size); 41 pageContext.setAttribute("content", content); 42 } 43 44 public static class UploadInvocation extends Invocation { 45 46 private FileUploaded uploadFile; 47 48 public FileUploaded getUploadFile() { 49 return uploadFile; 50 } 51 52 public void setUploadFile(FileUploaded uploadFile) { 53 this.uploadFile = uploadFile; 54 } 55 } 56 57 } 58 | Popular Tags |