(class)
public HttpForm
{inherits
Dialog}
Creates a specialized Dialog that can interact with CGI programs on a Web server.
Description
HttpForm is a section of a document containing normal content, links, controls and labels. Users "complete" a form by modifying its controls, before submitting the form to an agent for processing (e.g., to a Web server, to a mail server, etc.)
The function of
HttpForm is similar to the
<FORM> tag in HTML.
HttpForm can be nested, but only the controls directly inside a given
HttpForm are submitted in any given request.
To include hidden controls in a form, use any ordinary control (such as
TextField) and set the width and height to 0pt, or set the
Graphic.visible? property to false. (Note that an invisible control still occupies space on the screen if the width or height is nonzero.)
| constructor
public
| {HttpForm.default form-action:Url, method:HttpRequestMethod = HttpRequestMethod.get, encoding:String = HttpFormData.urlencoded-mime-type, target:String = "_self", default-character-encoding:CharEncoding = CharEncoding.ascii, ... } |
| default-character-encoding: | The default character encoding to use for the String parameters. It also specifies the character encoding used to convert the MIME related header and separator strings into bytes. |
field public HttpForm.default-character-encoding:
CharEncoding
| encoding: | The encoding type for the request sent to the server. |
field public HttpForm.encoding:
String
field public HttpForm.form-action:
Url
accessor public HttpForm.style-element:
String
field public HttpForm.target:
String ="_self"
Properties inherited from Visual:
_style-element, cursor, data-source, dragee, font-size, input-method-enabled?, input-method-keyboard-mode, name, options, style-class, style-manager, style-options, test-description, test-name, test-parent?, test-type-name, test-visible?, tooltip, user-data Properties inherited from Graphic:
avoid-page-break?, background, border-color, border-spec, border-style, border-width, cell-border-spec, cell-border-width, cell-margin, discrete-select-in-range?, display-context, enabled?, graphic-selectable, height, horigin, is-paginating?, layout, margin, opaque-to-events?, option-parent, outside-margin, pagination-state, parent, selection-context, shadow-color, shadow-spec, visible?, vorigin, width
|
public
| {HttpForm.add-file name:String, url:Url, content-type:#String = "application/octet-stream" }:void |
|
public
| {HttpForm.add-file-data name:String, data:{Array-of byte}, content-type:#String = "application/octet-stream", filename:String = "", content-transfer-encoding:#String = "binary" }:void |
|
public
| {HttpForm.async-submit-open submit-name:#String = null, submit-value:#String = null, character-encoding:CharEncoding = CharEncoding.none-specified, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, char
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false, event-handler:EventHandler, ...:EventHandler }:AsyncFileOpener |
|
public
| {HttpForm.async-submit-open-byte submit-name:#String = null, submit-value:#String = null, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, byte
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false, event-handler:EventHandler, ...:EventHandler }:AsyncFileOpener |
|
public
| {HttpForm.non-keyword-init-arg a:any}:void |
|
public
| {HttpForm.reset}:void |
|
public
| {HttpForm.reset-all}:void |
|
public
| {HttpForm.submit submit-name:#String = null, submit-value:#String = null }:void |
| submit-open: | Submits the HttpForm and obtains the response as a text stream. |
|
public
| {HttpForm.submit-open submit-name:#String = null, submit-value:#String = null, character-encoding:CharEncoding = CharEncoding.none-specified, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, char
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false }:HttpTextInputStream |
|
public
| {HttpForm.submit-open-byte submit-name:#String = null, submit-value:#String = null, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, byte
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false }:HttpByteInputStream |
Methods inherited from StandardActiveTraversalContainer:
add-internal, become-active, become-active-from-traversal, dispatch-mnemonic, get-sorted-traversors, internal-remove-child, on-key-press, react-to-child-change, register-active-traversor, traverse, traverse-from-visual, unregister-active-traversor Methods inherited from GuiEventTarget:
handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-out, on-grab-release, on-gui-event, on-input-method-event, on-key-event, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-press, on-pointer-release, on-pointer-scroll, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class Methods inherited from BaseFrame:
after-reposition, allocate-layout-object, attempt-revalidate-layout, before-reposition, compute-child-bounds, compute-parent-elastic, constrain-height, constrain-width, draw, end-pagination, get-height-preference, get-text, get-width-preference, install-child-bounds, note-attached, note-detaching, notify-option-children, paginate, pick-child, propagate-request-layout, register-options, set-size Methods inherited from Visual:
add-from-init-args, add-option, add-style-option, animate, change-cursor, clonable-appearance?, clone-appearance, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-view, maybe-fire-attach-event, maybe-fire-detach-event, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, release-key-focus, remove-option, remove-style-option, scroll-to-include, test-record, test-run, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-to-display-coordinates, transform-to-graphical-root-coordinates Methods inherited from OptionListInterface:
change-option-parent-notify, clone-options, get-option, get-option-by-name, keyword-init-arg, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-change-notify, option-lookup, option-set?, propagate-option-change, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name Methods inherited from Graphic:
create-pagination-state, detach, draw-range-as-selected, draw-shadow, find-ancestor, find-graphical-ancestor, fire-inferior-crossing-event, get-graphical-root, get-origin-in-graphical-ancestor, get-origin-in-root, get-pagination-state, get-top-left-in-ancestor, get-visible-bounds-into, on-drag-enter, on-inspection, on-pointer-enter, option-changed, paint-with-decorations, replace-with, request-draw, request-draw-rect, request-pointer-trace, search-next, search-prev, set-layout, start-pagination, xy-offset-to
(constructor)
| public
| {HttpForm.default form-action:Url, method:HttpRequestMethod = HttpRequestMethod.get, encoding:String = HttpFormData.urlencoded-mime-type, target:String = "_self", default-character-encoding:CharEncoding = CharEncoding.ascii, ... } |
Creates an HttpForm object.
form-action: The URL for the HTTP request. This is a positional argument.
method: The
HttpRequestMethod to use. Valid values are
HttpRequestMethod.get and
HttpRequestMethod.post.
encoding: The encoding type for the request sent to the server.
Use it to describe the format to use to send the form data to the server. It is either
HttpFormData.urlencoded-mime-type or
HttpFormData.multipart-mime-type.
HttpFormData.urlencoded-mime-type supports both the GET and the POST methods.
HttpFormData.multipart-mime-type supports only the POST method.
Calling
HttpForm.add-file or
HttpForm.add-file-data to add data to a
HttpForm means that the form must be submitted in multipart format. In this case, the only valid encoding is
HttpFormData.multipart-mime-type.
target: The browser window in which the form-action will be displayed. For more information, see
HttpForm.target.
default-character-encoding: The default character encoding to use for the
String parameters. This parameter also specifies the character encoding used to convert the MIME related header and separator strings into bytes.
Normally, you should use
CharEncoding.ascii or a superset of it, unless you need to use an encoding that does not have
CharEncoding.ascii as a subset for
HttpFormData.urlencoded-mime-type form data.
...: Rest arguments are passed to the
Dialog constructor.
You may pass
HttpFormParams. These parameters are added to the
HttpForm and will be submitted when the
HttpForm is submitted. Calling
HttpForm.reset will not remove these parameters. You will need to call
HttpForm.reset-all method in order to remove them.
Description
An
HttpForm will submit the values of each control it contains if the following conditions are met:
See the documentation of the
form-value getter for a control to see what it will return if its form is submitted. For example, see
ListBox.form-value.
(field)
The default character encoding to use for the String parameters. It also specifies the character encoding used to convert the MIME related header and separator strings into bytes.
Description
(field)
public HttpForm.encoding:
String The encoding type for the request sent to the server.
Description
Notes
HttpFormData.urlencoded-mime-type supports both the GET and the POST methods.
HttpFormData.multipart-mime-type supports only the POST method.
Calling
HttpForm.add-file or
HttpForm.add-file-data to add data to a
HttpForm means that the form must be submitted in multipart format. In this case, the only valid encoding is
HttpFormData.multipart-mime-type.
(field)
public HttpForm.form-action:
Url The URL for the HTTP request.
(accessor)
The HttpRequestMethod to use.
Description
Valid values are:
- HttpRequestMethod.get
Form values sent using HttpRequestMethod.get are sent as part of the URL. The information is called a query string and is included after a question mark in the URL. - HttpRequestMethod.post
Form values sent using HttpRequestMethod.post are sent as the body of an HTTP request.
(accessor)
accessor public HttpForm.style-element:
String The "element" or "type" of this Visual, for the purpose of styling.
Description
This implementation returns the value of
Visual._style-element but is normally overridden to return a constant value.
Overriding
If a subclass of
Visual should be stylable separately from other types of objects, this getter should be overridden to return an appropriate string. By convention, this string is the name of the class or the name of the markup that produces the object.
An override must return
self._style-element if it is not the empty string.
Introduced in:
version 6.0
(field)
public HttpForm.target:
String ="_self"
Specifies the browser window in which the result of the HttpForm.form-action will be displayed.
Description
Values for target are shown in the table below.
(method)
| public
| {HttpForm.add-file name:String, url:Url, content-type:#String = "application/octet-stream" }:void |
Adds a file to be submitted with this HttpForm.
name: The parameter name (for use by the server).
url: The path to the file to be added. Any valid
Url is allowed as long as the contents of the file can be read by the applet.
The filename part of this URL is added to the MIME header as the
filename.
The URL must contain only ASCII characters or be encoded according to RFC 2045.
If you want the user to select a file to be attached, use
choose-file or
choose-location.
content-type: Ideally the client would determine the type of content and supply a suitable MIME type string. If this is not possible, use "application/octet-stream" and the server or ultimate recipient can try to deduce the MIME type from the file name and/or from the data in the file.
Description
The specified file is added to the data to be submitted as a new file parameter. Call this method multiple times to add more than one file. All file parameters with the same parameter name will be sent to the server together.
Notes
(method)
| public
| {HttpForm.add-file-data name:String, data:{Array-of byte}, content-type:#String = "application/octet-stream", filename:String = "", content-transfer-encoding:#String = "binary" }:void |
Adds arbitrary data to be submitted with this HttpForm.
name: The parameter name for use by the server.
data: The data to be added to the form.
content-type: Ideally the client would determine the type of content and supply a suitable MIME type string. If this is not possible, use "application/octet-stream" and the server or ultimate recipient can try to deduce the MIME type from the file name and/or from the data in the file.
filename: If it is not null, a filename header will be included and will specify this name.
This string must contain only ASCII characters. If there is a possibility that it may not, it should be encoded according to RFC 2045.
content-transfer-encoding: This is the Content-Transfer-Encoding header value to be used for the file being added. null means no content-transfer-encoding header. If the applet has encoded the data being sent, this argument would be used to describe the encoding.
Description
The data provided is added to the data to be submitted as a new "part". Call this method multiple times to add more than one data part.
Notes
(method)
Adds a name and value pair to be submitted with this HttpForm.
name: The parameter name for use by the server.
value: The value to be added to the form corresponding to name.
Description
The specified name and value pair is added to the data to be submitted as a new parameter. Call this method multiple times to add more than one name and value pairs.
Notes
(method)
| public
| {HttpForm.async-submit-open submit-name:#String = null, submit-value:#String = null, character-encoding:CharEncoding = CharEncoding.none-specified, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, char
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false, event-handler:EventHandler, ...:EventHandler }:AsyncFileOpener |
Asynchronously submits an HttpForm for text input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the HttpTextInputStream that was opened.
submit-name, submit-value: If submit-name and submit-value are non-null, the name/value pair is submitted with the form. Both the name and the value are URL encoded before being submitted.
character-encoding: Indicates the character encoding to use when reading from the file. See
CharEncoding. If unspecified, the HTTP "charset" parameter from the
HttpHeaders.content-type will be used if it exists. If it does not exist, the character encoding is interpreted, if possible, from the first few bytes in the stream. When this is not possible, the default character encoding,
CharEncoding.utf8, is used.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
request-headers: Headers to be sent with the request.
auto-redirect?: If true, the request will be automatically redirected depending on status in response.
always-return-response-headers?: Overrides the default behavior when status in response header is not status-ok. Instead of raising an exception, returns a stream to allow access to response headers. Starting at version 1.7, the returned stream allows access to the response body as well as the response headers. As a consequence, the caller must call
HttpTextInputStream.close when done so the resources associated with the connection can be reclaimed.
Returns
Notes
(method)
| public
| {HttpForm.async-submit-open-byte submit-name:#String = null, submit-value:#String = null, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, byte
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false, event-handler:EventHandler, ...:EventHandler }:AsyncFileOpener |
Asynchronously submits an HttpForm for byte input, and calls the provided event handlers with an AsyncFileOpenEvent that contains either an exception or the HttpByteInputStream that was opened.
submit-name, submit-value: If submit-name and submit-value are non-null, the name/value pair is submitted with the form. Both the name and the value are URL encoded before being submitted.
buffer-size: Minimum number of
chars to be buffered. If
buffer-size and
unread-size are both
0, tries to make an unbuffered stream if possible. If either one is not
0, a
BufferedByteInputStream will be returned.
unread-size: Minimum number of
chars to be efficiently unreadable. If
buffer-size and
unread-size are both
0, tries to make an unbuffered stream if possible. If either is not
0, a
BufferedByteInputStream will be returned.
request-headers: Headers to be sent with the request.
auto-redirect?: If true, the request will be automatically redirected depending on status in response.
always-return-response-headers?: Overrides the default behavior when status in response header is not status-ok. Instead of raising an exception, returns a stream to allow access to response headers. Starting at version 1.7, the returned stream allows access to the response body as well as the response headers. As a consequence, the caller must call
HttpByteInputStream.close when done so the resources associated with the connection can be reclaimed.
Returns
Notes
(method)
| public
| {HttpForm.non-keyword-init-arg a:any}:void |
Invoked when InitRestArgParser.process-rest-args encounters a non-keyword argument.
Description
Visual's implementation of this method will first attempt to interpret the input to this method as meta-data to be associated with the object. For example,
EventHandlers and
DataBindings to be associated with the object are recognized and the appropriate steps are taken to attach them to the object.
Any input that cannot be understood as meta-data is assumed to be contents to be added to the
Visual and passed to
Visual.add-from-init-args.
Overriding
Override this method to accept additional meta-data associated with the object. Implementations should typically invoke the super implementation on inputs that they fail to interpret.
(method)
Register a Control with this ControlContainer.
Description
Controls should call this in their control-container option handler.
c: The control to register.
Overriding
Override this to keep track of the registered controls.
(method)
| public
| {HttpForm.reset}:void |
Resets the controls in the form to their initial values. It also removes all the data that was added to this form using the methods HttpForm.add-file, HttpForm.add-file-data or HttpForm.add-string-param. This method then calls Dialog.reset.
Any HttpFormParams that where added during the construction of this HttpForm will not be removed.
Notes
Only the controls that have a non-null name will be set to their initial values. However all the controls in the form will be sent a
Reset event.
The procedure
reset-button can be used to easily add a standard reset button to a form.
(method)
| public
| {HttpForm.reset-all}:void |
(method)
| public
| {HttpForm.submit submit-name:#String = null, submit-value:#String = null }:void |
Submits the form and browses to HttpForm.form-action.
Notes
The procedure
submit-button can be used to easily add a standard submit button to a form.
submit-name, submit-value: If submit-name and submit-value are non-null, the name/value pair is submitted with the form. Both the name and the value are URL encoded before being submitted.
(method)
| public
| {HttpForm.submit-open submit-name:#String = null, submit-value:#String = null, character-encoding:CharEncoding = CharEncoding.none-specified, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, char
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false }:HttpTextInputStream |
Submits the HttpForm and obtains the response as a text stream.
submit-name, submit-value: If submit-name and submit-value are non-null, the name/value pair is submitted with the form. Both the name and the value are URL encoded before being submitted.
character-encoding: Indicates the character encoding to use when reading from the text stream. See
CharEncoding. If unspecified, the HTTP "charset" parameter from the
HttpHeaders.content-type will be used if it exists. If it does not exist, the character encoding is interpreted, if possible, from the first few bytes in the stream. When this is not possible, the default character encoding,
CharEncoding.windows-latin-1, is used.
buffer-size: Minimum number of chars to be buffered. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
unread-size: Minimum number of chars to be efficiently unreadable. If buffer-size and unread-size are both 0, tries to make an unbuffered stream if possible.
request-headers: Headers to be sent with the request.
auto-redirect?: If true, the request will be automatically redirected depending on status in response.
always-return-response-headers?: Overrides the default behavior when status in response header is not status-ok. Instead of raising an exception, returns a stream to allow access to response headers. Starting at version 1.7, the returned stream allows access to the response body as well as the response headers. As a consequence, the caller must call
HttpTextInputStream.close when done so the resources associated with the connection can be reclaimed.
Returns
Description
Notes
(method)
| public
| {HttpForm.submit-open-byte submit-name:#String = null, submit-value:#String = null, buffer-size:int = {calculate-instances-per-memory-size
default-buffer-memory-size, byte
}, unread-size:int = {min 4, buffer-size div 4}, request-headers:#HttpRequestHeaders = null, auto-redirect?:bool = true, always-return-response-headers?:bool = false }:HttpByteInputStream |
Submits the form and obtains the response as a byte stream.
submit-name, submit-value: If submit-name and submit-value are non-null, the name/value pair is submitted with the form. Both the name and the value are URL encoded before being submitted.
buffer-size: Minimum number of
chars to be buffered. If
buffer-size and
unread-size are both
0, tries to make an unbuffered stream if possible. If either one is not
0, a
BufferedByteInputStream will be returned.
unread-size: Minimum number of
chars to be efficiently unreadable. If
buffer-size and
unread-size are both
0, tries to make an unbuffered stream if possible. If either is not
0, a
BufferedByteInputStream will be returned.
request-headers: Headers to be sent with the request.
auto-redirect?: If true, the request will be automatically redirected depending on status in response.
always-return-response-headers?: Overrides the default behavior when status in response header is not status-ok. Instead of raising an exception, returns a stream to allow access to response headers. Starting at version 1.7, the returned stream allows access to the response body as well as the response headers. As a consequence, the caller must call
HttpByteInputStream.close when done so the resources associated with the connection can be reclaimed.
Returns
Description
The returned stream inherits from
HttpInputStreamInfo.
HttpInputStreamInfo provides an interface to access the response headers.
Notes
(method)
Unregister a Control from this ControlContainer.
Description
Controls should call this in their control-container option handler when they are removed from a container.
c: The control to unregister.
Overriding
Override this to keep track of the registered controls.