org.zkoss.zk.au.http
Class AuDropUploader

java.lang.Object
  extended by org.zkoss.zk.au.http.AuDropUploader
All Implemented Interfaces:
AuExtension

public class AuDropUploader
extends java.lang.Object
implements AuExtension

The AU extension to upload files with HTML5 feature. It is based on Apache Commons File Upload.

Since:
6.5.0

Constructor Summary
AuDropUploader()
           
 
Method Summary
 void destroy()
          Destroys the AU extension.
protected  java.lang.String handleError(java.lang.Throwable ex)
          Handles the exception that was thrown when uploading files, and returns the error message.
 void init(DHtmlUpdateServlet servlet)
          Initializes the AU extension.
static boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
          Returns whether the request contains multipart content.
 void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String pathInfo)
          Processes a file uploaded from the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuDropUploader

public AuDropUploader()
Method Detail

init

public void init(DHtmlUpdateServlet servlet)
Description copied from interface: AuExtension
Initializes the AU extension. It is called when an extension is added to DHtmlUpdateServlet.

Specified by:
init in interface AuExtension

destroy

public void destroy()
Description copied from interface: AuExtension
Destroys the AU extension. It is called when an extension is removed from DHtmlUpdateServlet, or when DHtmlUpdateServlet is being destroyed.

Specified by:
destroy in interface AuExtension

service

public void service(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response,
                    java.lang.String pathInfo)
             throws javax.servlet.ServletException,
                    java.io.IOException
Processes a file uploaded from the client.

Specified by:
service in interface AuExtension
Parameters:
request - the request (never null).
response - the response (never null).
pathInfo - the path info. It includes the prefix when the Au processor is associated (see DHtmlUpdateServlet.addAuExtension(org.zkoss.zk.ui.WebApp, java.lang.String, org.zkoss.zk.au.http.AuExtension). For example, if an AU processor is associated with "/upload", then pi must start with "/upload". Note: it might end with other string depending on the URI you generated to the client.
Throws:
javax.servlet.ServletException
java.io.IOException

handleError

protected java.lang.String handleError(java.lang.Throwable ex)
Handles the exception that was thrown when uploading files, and returns the error message. When uploading file(s) causes an exception, this method will be called to generate the proper error message.

By default, it logs the error and then use Exceptions.getMessage(java.lang.Throwable) to retrieve the error message.

If you prefer not to log or to generate the custom error message, you can extend this class and override this method. Then, specify it in web.xml as follows. (we change from processor0 to extension0 after ZK5.)

Parameters:
ex - the exception. Typical exceptions include org.apache.commons.fileupload .FileUploadBase.SizeLimitExceededException
Since:
3.0.4
See Also:
<servlet>
  <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
  <init-param>
    <param-name>extension0</param-name>
    <param-value>/upload=com.my.MyUploader</param-value>
  </init-param>
...

isMultipartContent

public static final boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
Returns whether the request contains multipart content.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo