1 20 package org.enhydra.barracuda.contrib.dbroggisch.examples.controller.handlers; 21 22 import java.io.IOException ; 23 import java.util.ArrayList ; 24 import java.util.List ; 25 import java.util.Enumeration ; 26 import javax.servlet.ServletException ; 27 import javax.servlet.http.HttpServletRequest ; 28 import org.enhydra.barracuda.core.event.ControlEventContext; 29 import org.enhydra.barracuda.core.event.EventException; 30 import org.enhydra.barracuda.core.helper.servlet.DefaultServletRequestWrapper; 31 import org.enhydra.barracuda.contrib.dbroggisch.page.Page; 32 import org.enhydra.barracuda.contrib.dbroggisch.page.PageEventListener; 33 34 import org.enhydra.barracuda.contrib.dbroggisch.examples.controller.DBRApplicationGateway; 35 import org.enhydra.barracuda.contrib.dbroggisch.examples.controller.servlets.MyMultipartRequest; 36 import org.enhydra.barracuda.contrib.dbroggisch.examples.view.pages.*; 37 38 39 public class FileUploadHandler extends PageEventListener { 40 41 public void handleControlEvent(ControlEventContext context, Page p) 42 throws EventException, ServletException , IOException { 43 HttpServletRequest request = context.getRequest(); 44 List realNames = new ArrayList (); 45 FileUploadPage fuPage = (FileUploadPage)p; 46 fuPage.setState(ExampleBasePage.FILEUPLOAD); 47 48 if (DBRApplicationGateway.WRAPPER_INSTALLED && 49 ((DefaultServletRequestWrapper)request).getCoreRequest() instanceof MyMultipartRequest) { 50 MyMultipartRequest mReq = (MyMultipartRequest)((DefaultServletRequestWrapper)request).getCoreRequest(); 51 Enumeration fnames = mReq.getFileNames(); 52 53 while(fnames.hasMoreElements()) { 54 realNames.add(mReq.getFilesystemName((String )fnames.nextElement())); 55 } 56 } 57 fuPage.setNames(realNames); 58 context.getEvent().setHandled(true); 59 } 60 61 } 62 | Popular Tags |