Class: TupelList

$.web. TupelList

$.web.TupelList Represents a list of name-value pairs.

new TupelList()

A list of name-value pairs. The TupelList is a container that provides tuples for cookies, headers, and parameters. A tuple is a JavaScript object with the properties "name" and "value". The list can be iterated and it also provides a method to query the values for a given name.
Example
var i;
for (i = 0; i < $.request.parameters.length; ++i) {
    var name = $.request.parameters[i].name;
    var value = $.request.parameters[i].value;
    ...
}

Members

length :number

The size of the TupelList
Type:
  • number

Methods

get(name) → {string}

Returns the values for a given name.
Parameters:
Name Type Description
name string Represents the names of the tuple whose values are to be queried.
Returns:
Returns a single string. If multiple values are found, the first one is returned, undefined otherwise.
Type
string

remove(name)

Removes the value for a given name. This is only allowed for TupelLists of $.response and $.net.http.Request objects.
Parameters:
Name Type Description
name string The name of the tuple to be removed.
Throws:
Throws an error if the tuple cannot be removed or if the argument is invalid.

set(name, value) → {boolean}

Sets the value for a given name.
The method will either add a new tuple to the list or modify the existing list. This is only allowed for TupelLists of $.response and $.net.http.Request objects.
Parameters:
Name Type Description
name string The name of the tuple to be modified.
value string The value to be set.
Throws:
Throws an error if the tuple cannot be set.
Returns:
Returns true if the tuple can be set.
Type
boolean

set(name, value, options) → {boolean}

Special setter for cookies.
The method will either add a new cookie to the list or modify the cookie in the list. This is only allowed for the TupleList cookie property of $.response and $.net.http.Request objects.
This setter also accepts a metadata object that control the cookie metadata.
Parameters:
Name Type Argument Description
name string The name of the tuple to be modified.
value string The value to be set.
options object <optional>
metadata The metadata of the cookie to be set:
  • path - string
  • domain - string
  • expires - string
  • secure - boolean
  • httpOnly - boolean
Throws:
Throws an error if the tuple cannot be set.
Returns:
Returns true if the tuple can be set.
Type
boolean
Example
var d = new Date();
d.setSeconds(d.getSeconds() + 3600); // cookie is valid one hour from now

$.response.cookies.set("myCookie", "theValue", { expires: d.toUTCString(), path: "/myApp", httpOnly: false });
$.response.cookies.set("myCookie2", "theValue2", { path: "/myApp2", secure: true });