OverviewSingleDeprecated

jsx3.net

class Form

Object
->jsx3.lang.Object
  ->jsx3.net.Form

All Implemented Interfaces:

jsx3.util.EventDispatcher

class Form
extends jsx3.lang.Object
Provides support for legacy HTML GET and POST forms. Allows the submission of forms with arbitrary key-value pairs as well as file upload.

Prompting the user for a file upload field (promptForFile()) is only supported in Microsoft Internet Explorer.

Since:

3.0

Field Summary
static String
EVENT_FILE_SELECTED
Event type published when a file has been chosen through user interaction.
static String
EVENT_ON_ERROR
Event type published when a security error occurs trying to access the response.
static String
EVENT_ON_RESPONSE
Event type published when the response has loaded.
static String
EVENT_ON_TIMEOUT
Event type published when the response is still not ready after the specified timeout period.
static String
METHOD_GET
static String
METHOD_POST
Constructor Summary
void
init(strMethod : String, strAction : String, bMultipart : boolean)
instance initializer
Method Summary
void
Stops polling for a response.
void
Adds a file upload field to this form.
void
Hides the IFRAME containing this form after it has been shown by calling reveal().
void
Destroys the form and the hidden IFRAME.
String
Returns the action of this form, the URL that this form is submitted to.
String
getField(strName : String)
Returns the value of a field in this form.
Array<String>
Returns the names of all fields in this form.
String
Returns the method of this form.
boolean
Returns whether this form is multipart.
String
Returns the content of the response as a string.
jsx3.xml.Document
Returns the content of the response as an XML document.
static jsx3.net.Form
newFromFragment(strFragment : String)
Creates a new form and initialize it from the HTML representation of a form.
void
promptForFile(strFieldName : String)
Invokes the operating system file browser to choose a file for a file upload field.
void
removeField(strName : String)
Removes a field from this form.
void
reveal(l : int, t : int, w : int, h : int)
Reveals the IFRAME containing this form for debugging purposes.
void
send(intPollInterval : int, intTimeout : int)
Sends the form.
void
send(intPollInterval : int, intTimeout : int)
Sends the form.
void
setAction(action : String)
Sets the action of this form.
void
setField(strName : String, strValue : String, bConcat : boolean)
Sets the value of a field in this form.
void
setMethod(method : String)
Sets the method of this form.
void
setMultipart(multipart : boolean)
Sets whether this form is multipart.
Methods Inherited From jsx3.util.EventDispatcher
publish, subscribe, unsubscribe, unsubscribeAll
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf, toString
Field Detail

EVENT_FILE_SELECTED

static final String EVENT_FILE_SELECTED
Event type published when a file has been chosen through user interaction. The event has properties field and value.

EVENT_ON_ERROR

static final String EVENT_ON_ERROR
Event type published when a security error occurs trying to access the response.

EVENT_ON_RESPONSE

static final String EVENT_ON_RESPONSE
Event type published when the response has loaded.

EVENT_ON_TIMEOUT

static final String EVENT_ON_TIMEOUT
Event type published when the response is still not ready after the specified timeout period.

METHOD_GET

static final String METHOD_GET

METHOD_POST

static final String METHOD_POST
Constructor Detail

init

void init(strMethod : String, strAction : String, bMultipart : boolean)
instance initializer

Parameters:

strMethodform method, METHOD_GET (default) or METHOD_POST
strActionthe URL to submit to
bMultipartif true the form can support file upload
Method Detail

abort

void abort()
Stops polling for a response.

addFileUploadField

void addFileUploadField(strName : String)
Adds a file upload field to this form.

Parameters:

strNamethe name of the new field.

conceal

void conceal()
Hides the IFRAME containing this form after it has been shown by calling reveal().

Since:

3.2

See Also:

reveal()

destroy

void destroy()
Destroys the form and the hidden IFRAME. This method should be called after receiving an onResponse, onError, or onTimeout event for proper garbage collection.

getAction

String getAction()
Returns the action of this form, the URL that this form is submitted to.

Returns:

action  

getField

String getField(strName : String)
Returns the value of a field in this form.

Parameters:

strNamethe name of the form field to query.

Returns:

the field value or null if no such field exists.  

getFields

Array<String> getFields()
Returns the names of all fields in this form.

Returns:

 

getMethod

String getMethod()
Returns the method of this form.

Returns:

METHOD_GET or METHOD_POST.  

getMultipart

boolean getMultipart()
Returns whether this form is multipart. Only multipart forms may upload files.

Returns:

 

getResponseText

String getResponseText()
Returns the content of the response as a string.

Returns:

 

getResponseXML

jsx3.xml.Document getResponseXML()
Returns the content of the response as an XML document.

Returns:

 

newFromFragment

static jsx3.net.Form newFromFragment(strFragment : String)
Creates a new form and initialize it from the HTML representation of a form.

Parameters:

strFragmentthe html fragment containing a
tag.

Throws:

an error if the fragment was not well-formed or did not contain a form tag.

Returns:

 

promptForFile

void promptForFile(strFieldName : String)
Invokes the operating system file browser to choose a file for a file upload field. This method is not supported in browsers other than Microsoft Internet Explorer.

Parameters:

strFieldNamethe name of the file upload field.

removeField

void removeField(strName : String)
Removes a field from this form.

Parameters:

strNamethe name of the form field to remove.

reveal

void reveal(l : int, t : int, w : int, h : int)
Reveals the IFRAME containing this form for debugging purposes. Dimensions of the revealed form may be provided or a default position and dimensions will be used.

Parameters:

lpixels from the left side of the HTML page that the IFRAME will be displayed.
tpixels from the top of the HTML page that the IFRAME will be displayed.
wwidth of the revealed IFRAME, in pixels.
hheight of the revealed IFRAME, in pixels.

Since:

3.2

See Also:

conceal()

send

void send(intPollInterval : int, intTimeout : int)
Sends the form. Sending the form is always asynchronous. Once a form has been sent it may not be reused.

Parameters:

intPollIntervalmilliseconds between checking for a response. If not provided, the default value is 1/4 sec.
intTimeouttotal milliseconds before timeout. If not provided, the default value is 30 sec.

send

void send(intPollInterval : int, intTimeout : int)
Sends the form. Sending the form is always asynchronous. Once a form has been sent it may not be reused.

Parameters:

intPollIntervalmilliseconds between checking for a response. If not provided, the default value is 1/4 sec.
intTimeouttotal milliseconds before timeout. If not provided, the default value is 30 sec.

setAction

void setAction(action : String)
Sets the action of this form.

Parameters:

action

setField

void setField(strName : String, strValue : String, bConcat : boolean)
Sets the value of a field in this form.

Parameters:

strNamethe name of the form field to set.
strValuethe new value of form field.
bConcatif true, will append " " + strValue to the existing value. The space is only inserted if the existing value is not empty.

setMethod

void setMethod(method : String)
Sets the method of this form.

Parameters:

methodMETHOD_GET or METHOD_POST.

setMultipart

void setMultipart(multipart : boolean)
Sets whether this form is multipart.

Parameters:

multipart