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 class.

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(EN_SOME_ERROR,"/some/url/file.img","file.img","no error"):

Since:
2.4
Version:
$Id: UploadResponse.java 1966 2008-05-08 10:43:36Z th-schwarz $

Field Summary
static int EN_ERROR
          Error number ERROR
static int EN_INVALID_EXTENSION
          Error number INVALID EXTENSION
static int EN_OK
          Error number OK
static int EN_RENAMED
          Error number RENAMED
static int EN_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

EN_OK

public static final int EN_OK
Error number OK

See Also:
Constant Field Values

EN_ERROR

public static final int EN_ERROR
Error number ERROR

See Also:
Constant Field Values

EN_RENAMED

public static final int EN_RENAMED
Error number RENAMED

See Also:
Constant Field Values

EN_INVALID_EXTENSION

public static final int EN_INVALID_EXTENSION
Error number INVALID EXTENSION

See Also:
Constant Field Values

EN_SECURITY_ERROR

public static final int EN_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(EN_OK,"/some/url/to/pic.jpg","pic") or UploadResponse(EN_OK) but not UploadResponse(EN_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-2008 Frederico Caldeira Knabben. All Rights Reserved.