net.fckeditor.response
Class UploadResponse

java.lang.Object
  extended by net.fckeditor.response.UploadResponse

public class UploadResponse
extends java.lang.Object

Simply abstracts from the JavaScript callback to a Java object.

The usage is quite easy but can be tricky since varargs are used in the class constructor.
The requestor expects a JS method callback with variable arguments size.

e.g. window.parent.OnUploadCompleted(101,'some/url/file.img','file.img','no error');

The UploadResponse constructor behaves the same way by simply calling it with:
UploadResponse ur = new UploadResonse(SC_SOME_ERROR,"/some/url/file.img","file.img","no error"):

Version:
$Id: UploadResponse.java 3840 2009-07-08 20:29:46Z mosipov $

Field Summary
static int SC_ERROR
          Error number ERROR
static int SC_INVALID_EXTENSION
          Error number INVALID EXTENSION
static int SC_OK
          Error number OK
static int SC_RENAMED
          Error number RENAMED
static int SC_SECURITY_ERROR
          Error number SECURITY ERROR
static UploadResponse UR_INVALID_CURRENT_FOLDER
          UploadResponse INVALID CURRENT FOLDER
 
Constructor Summary
UploadResponse(java.lang.Object... arguments)
          Constructs the response with variable amount of parameters.
 
Method Summary
 void setCustomMessage(java.lang.String customMassage)
          Sets the message in the UploadResponse.
 java.lang.String toString()
          Assembles the JavaScript method for the user callback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SC_OK

public static final int SC_OK
Error number OK

See Also:
Constant Field Values

SC_ERROR

public static final int SC_ERROR
Error number ERROR

See Also:
Constant Field Values

SC_RENAMED

public static final int SC_RENAMED
Error number RENAMED

See Also:
Constant Field Values

SC_INVALID_EXTENSION

public static final int SC_INVALID_EXTENSION
Error number INVALID EXTENSION

See Also:
Constant Field Values

SC_SECURITY_ERROR

public static final int SC_SECURITY_ERROR
Error number SECURITY ERROR

See Also:
Constant Field Values

UR_INVALID_CURRENT_FOLDER

public static final UploadResponse UR_INVALID_CURRENT_FOLDER
UploadResponse INVALID CURRENT FOLDER

Constructor Detail

UploadResponse

public UploadResponse(java.lang.Object... arguments)
               throws java.lang.IllegalArgumentException
Constructs the response with variable amount of parameters.

Put the desired parameters in the constructor. You may omit them from right to left but you have to remain the order.
e.g. UploadResponse(SC_OK,"/some/url/to/pic.jpg","pic") or UploadResponse(SC_OK) but not UploadResponse(SC_OK,"some error message")

Use, if possible, the pre-defined error numbers or upload responses.

If you need to set error number and message only, use constructor with one parameter and call setCustomMessage(String).

Parameters:
arguments - possible argument order: int errorNumber, String fileUrl, String filename, String customMessage
Throws:
java.lang.IllegalArgumentException - if amount of arguments is less than 1 and above 4
java.lang.IllegalArgumentException - if the first argument is not an error number (int)
Method Detail

setCustomMessage

public void setCustomMessage(java.lang.String customMassage)
Sets the message in the UploadResponse. Methods automatically determines how many arguments are set and puts the message at the end.

Parameters:
customMassage - the message you want to pass to the user

toString

public java.lang.String toString()
Assembles the JavaScript method for the user callback

Overrides:
toString in class java.lang.Object


Copyright © 2004-2009 Frederico Caldeira Knabben. All Rights Reserved.