1 17 package org.apache.geronimo.console; 18 19 import org.apache.commons.fileupload.portlet.PortletFileUpload; 20 21 import javax.portlet.PortletRequestDispatcher; 22 import javax.portlet.PortletConfig; 23 import javax.portlet.PortletException; 24 import javax.portlet.ActionRequest; 25 import javax.portlet.ActionResponse; 26 import javax.portlet.RenderRequest; 27 import javax.portlet.RenderResponse; 28 import javax.enterprise.deploy.spi.status.ProgressObject ; 29 import java.io.IOException ; 30 import java.util.Map ; 31 import java.util.HashMap ; 32 import java.util.Properties ; 33 34 41 public abstract class MultiPageAbstractHandler { 42 protected final static String BEFORE_ACTION="-before"; 43 protected final static String AFTER_ACTION="-after"; 44 protected PortletRequestDispatcher view; 45 private final String mode; 46 private final String viewName; 47 private Map uploadFiles = new HashMap (); 48 private Properties uploadFields = new Properties (); 49 50 protected MultiPageAbstractHandler(String mode, String viewName) { 51 this.mode = mode; 52 this.viewName = viewName; 53 } 54 55 public String getMode() { 56 return mode; 57 } 58 59 public void init(PortletConfig portletConfig) throws PortletException { 60 if(viewName != null) { 61 view = portletConfig.getPortletContext().getRequestDispatcher(viewName); 62 } 63 } 64 65 public void destroy() { 66 view = null; 67 } 68 69 public PortletRequestDispatcher getView() { 70 return view; 71 } 72 73 protected static boolean isEmpty(String s) { 74 return s == null || s.trim().equals(""); 75 } 76 77 80 public abstract String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException ; 81 82 public abstract void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException ; 83 84 87 public abstract String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException ; 88 89 public Map getUploadFiles() { 90 return uploadFiles; 91 } 92 93 public Properties getUploadFields() { 94 return uploadFields; 95 } 96 97 protected static void waitForProgress(ProgressObject po) { 98 while(po.getDeploymentStatus().isRunning()) { 99 try { 100 Thread.sleep(100); 101 } catch (InterruptedException e) { 102 e.printStackTrace(); 103 } 104 } 105 } 106 107 } 108 | Popular Tags |