Web Component


Properties

allowCookies
  Specifies whether cookies should be allowed
Data type: boolean
Designer Writable true <web name="webName" allowCookies="true">
Code Writeable true webName.allowCookies = true
Code Readable true let variable = webName.allowCookies

requestHeaders
  Sets the request headers.
Data type: array
Designer Writable false
Code Writeable true webName.requestHeaders =
Code Readable true let variable = webName.requestHeaders

responseFileName
  Specifies the name of the file where the response should be saved. If SaveResponse is true and ResponseFileName is empty, then a new file name will be generated.
Data type: string
Designer Writable true <web name="webName" responseFileName="Test responseFileName">
Code Writeable true webName.responseFileName = "Test responseFileName"
Code Readable true let variable = webName.responseFileName

saveResponse
  Specifies whether the response should be saved in a file.
Data type: boolean
Designer Writable true <web name="webName" saveResponse="true">
Code Writeable true webName.saveResponse = true
Code Readable true let variable = webName.saveResponse

timeout
  Returns the number of milliseconds that each request will wait for a response before they time out. If set to 0, then the request will wait for a response indefinitely.
Data type: number
Designer Writable true <web name="webName" timeout="3000">
Code Writeable true webName.timeout = 3000
Code Readable true let variable = webName.timeout

url
  Specifies the URL.
Data type: string
Designer Writable true <web name="webName" url="http://www.google.com">
Code Writeable true webName.url = "http://www.google.com"
Code Readable true let variable = webName.url

class
  The styling class of the the component
Data type: string
Designer Writable true <web name="webName" class="Test class">
Code Writeable false
Code Readable false

id
  The styling id of the the component
Data type: string
Designer Writable true <web name="webName" id="Test id">
Code Writeable false
Code Readable false

name
  The name of the component that will be used to refer to it in code.
Data type: string
Designer Writable true <web name="webName" name="testComponent">
Code Writeable false
Code Readable false

Methods

Method name Description Parameters
buildRequestData Converts a list of two-element sublists, representing name and value pairs, to a string formatted as application/x-www-form-urlencoded media type, suitable to pass to PostText.
webName.buildRequestData(list)
webName.buildRequestData()
list list
clearCookies Clears all cookies for this Web component.
webName.clearCookies()
delete Performs an HTTP DELETE request using the Url property and retrieves the response. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.delete()
get Performs an HTTP GET request using the Url property and retrieves the response. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.get()
htmlTextDecode Decodes the given HTML text value. HTML Character Entities such as &amp;, &lt;, &gt;, &apos;, and &quot; are changed to &, <, >, ', and ". Entities such as &#xhhhh;, and &#nnnn; are changed to the appropriate characters.
webName.htmlTextDecode(htmlText)
webName.htmlTextDecode("

test para

>")
htmlText string
jsonObjectEncode Returns the value of a built-in type (i.e., boolean, number, text, list, dictionary) in its JavaScript Object Notation representation. If the value cannot be represented as JSON, the Screen's ErrorOccurred event will be run, if any, and the Web component will return the empty string.
webName.jsonObjectEncode(jsonObject)
webName.jsonObjectEncode(any)
jsonObject any
jsonTextDecode Decodes the given JSON encoded value to produce a corresponding AppInventor value. A JSON list [x, y, z] decodes to a list (x y z), A JSON object with key A and value B, (denoted as {A:B}) decodes to a list ((A B)), that is, a list containing the two-element list (A B). Use the method JsonTextDecodeWithDictionaries if you would prefer to get back dictionary objects rather than lists-of-lists in the result.
webName.jsonTextDecode(jsonText)
webName.jsonTextDecode("[1,2,3,4,5]")
jsonText string
jsonTextDecodeWithDictionaries Decodes the given JSON encoded value to produce a corresponding App Inventor value. A JSON list [x, y, z] decodes to a list (x y z). A JSON Object with name A and value B, denoted as {a: b} decodes to a dictionary with the key a and value b.
webName.jsonTextDecodeWithDictionaries(jsonText)
webName.jsonTextDecodeWithDictionaries("[{\"a\":1,\"b\":2},{\"c\":3,\"d\":4}]")
jsonText string
patchFile Performs an HTTP PATCH request using the Url property and data from the specified file. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.patchFile(path)
webName.patchFile("Test path")
path string
patchText Performs an HTTP PATCH request using the Url property and the specified text. The characters of the text are encoded using UTF-8 encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.patchText(text)
webName.patchText("Test text")
text string
patchTextWithEncoding Performs an HTTP PATCH request using the Url property and the specified text. The characters of the text are encoded using the given encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.patchTextWithEncoding(text, encoding)
webName.patchTextWithEncoding("Test text", "UTF-8")
text string
encoding string
postFile Performs an HTTP POST request using the Url property and data from the specified file. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.postFile(path)
webName.postFile("Test path")
path string
postText Performs an HTTP POST request using the Url property and the specified text. The characters of the text are encoded using UTF-8 encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.postText(text)
webName.postText("Test text")
text string
postTextWithEncoding Performs an HTTP POST request using the Url property and the specified text. The characters of the text are encoded using the given encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.postTextWithEncoding(text, encoding)
webName.postTextWithEncoding("Test text", "UTF-8")
text string
encoding string
putFile Performs an HTTP PUT request using the Url property and data from the specified file. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.putFile(path)
webName.putFile("Test path")
path string
putText Performs an HTTP PUT request using the Url property and the specified text. The characters of the text are encoded using UTF-8 encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.putText(text)
webName.putText("Test text")
text string
putTextWithEncoding Performs an HTTP PUT request using the Url property and the specified text. The characters of the text are encoded using the given encoding. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.
webName.putTextWithEncoding(text, encoding)
webName.putTextWithEncoding("Test text", "UTF-8")
text string
encoding string
uriDecode Decodes the encoded text value so that the values aren't URL encoded anymore.
webName.uriDecode(text)
webName.uriDecode("Test text")
text string
uriEncode Encodes the given text value so that it can be used in a URL.
webName.uriEncode(text)
webName.uriEncode("Test text")
text string
XMLTextDecode Decodes the given XML string to produce a list structure. <tag>string</tag> decodes to a list that contains a pair of tag and string. More generally, if obj1, obj2, ... are tag-delimited XML strings, then <tag>obj1 obj2 ...</tag> decodes to a list that contains a pair whose first element is tag and whose second element is the list of the decoded obj's, ordered alphabetically by tags.
webName.XMLTextDecode(XmlText)
webName.XMLTextDecode("Test XmlText")
XmlText string
XMLTextDecodeAsDictionary Decodes the given XML string to produce a dictionary structure. The dictionary includes the special keys $tag, $localName, $namespace, $namespaceUri, $attributes, and $content, as well as a key for each unique tag for every node, which points to a list of elements of the same structure as described here. The $tag key is the full tag name, e.g., foo:bar. The $localName is the local portion of the name (everything after the colon : character). If a namespace is given (everything before the colon : character), it is provided in $namespace and the corresponding URI is given in $namespaceUri. The attributes are stored in a dictionary in $attributes and the child nodes are given as a list under $content.
webName.XMLTextDecodeAsDictionary(XmlText)
webName.XMLTextDecodeAsDictionary("Test XmlText")
XmlText string
addEventListener Method used to create event listeners.
See Events below for samples.
eventName string
eventCallbackFunction callback

Events

Event name Description Parameters
gotFile Event indicating that a request has finished.
webName.addEventListener(
    "gotFile",
    function (url, responseCode, responseType, fileName) {
        //Your code here
    }
)
url string
responseCode number
responseType string
fileName string
gotText Event indicating that a request has finished.
webName.addEventListener(
    "gotText",
    function (url, responseCode, responseType, responseContent) {
        //Your code here
    }
)
url string
responseCode number
responseType string
responseContent string
timedOut Event indicating that a request has timed out.
webName.addEventListener(
    "timedOut",
    function (url) {
        //Your code here
    }
)
url string