Deprecated. The UI service was deprecated on December 11, 2014. To create user interfaces, use the HTML service instead.
An event handler that runs in the user's browser without needing a call back to the server. These
will, in general, run much faster than
s but they are also more limited in
what they can do.
ServerHandler
Any method that accepts a "Handler" parameter can accept a ClientHandler.
If you set validators on a ClientHandler, they will be checked before the handler performs its actions. The actions will only be performed if the validators succeed.
If you have multiple ClientHandlers for the same event on the same widget, they will perform their actions in the order that they were added.
An example of using client handlers:
function doGet() { var app = UiApp.createApplication(); var button = app.createButton("Say Hello"); // Create a label with the "Hello World!" text and hide it for now var label = app.createLabel("Hello World!").setVisible(false); // Create a new handler that does not require the server. // We give the handler two actions to perform on different targets. // The first action disables the widget that invokes the handler // and the second displays the label. var handler = app.createClientHandler() .forEventSource().setEnabled(false) .forTargets(label).setVisible(true); // Add our new handler to be invoked when the button is clicked button.addClickHandler(handler); app.add(button); app.add(label); return app; }
Deprecated methods
Method | Return type | Brief description |
---|---|---|
|
| Sets the target of this handler for subsequent directives to be whatever widget triggered the event that this handler was called for. |
|
| Sets the target of this handler for subsequent directives to be the given widgets. |
| String | Returns the id that has been assigned to this object. |
| String | Gets the text tag of this . |
| String | Gets the type of this object. |
|
| A directive to set the enabled/disabled state of the widgets this handler is targeted to. |
|
| A directive to set the html text of the widgets this handler is targeted to. |
|
| Sets the id of this . |
|
| A directive to set a style attribute on a grid element. |
|
| A directive to set a style attribute on the widgets the handler is targeted to. |
|
| A directive to set multiple style attributes on a grid element. |
|
| A directive to set multiple style attributes on the widgets the handler is targeted to. |
|
| Sets the text tag of this . |
|
| A directive to set the text of the widgets this handler is targeted to. |
|
| A directive to set the boolean value of the widgets this handler is targeted to. |
|
| A directive to set the visibility of the widgets this handler is targeted to. |
|
| Sets this handler to fire only if the given widget's value is a valid email address. |
|
| Sets this handler to fire only if the given widget's value can be interpreted as an integer. |
|
| Sets this handler to fire only if the given widget's value is a string whose length is between min and max. |
|
| Sets this handler to fire only if the given widget's value matches this regular expression. |
|
| Sets this handler to fire only if the given widget's value matches this regular expression. |
|
| Sets this handler to fire only if the given widget's value is not a valid email address. |
|
| Sets this handler to fire only if the given widget's value cannot be interpreted as an integer. |
|
| Sets this handler to fire only if the given widget's value is a string whose length is less than min or greater than max. |
|
| Sets this handler to fire only if the given widget's value does not match this regular expression. |
|
| Sets this handler to fire only if the given widget's value does not match this regular expression. |
|
| Sets this handler to fire only if the given widget's value cannot be interpreted as an number. |
|
| Sets this handler to fire only if the given widget's value is not one of the strings given in the options parameter. |
|
| Sets this handler to fire only if the given widget's value cannot be interpreted as a number that is between min and max. |
|
| Sets this handler to fire only if the given widgets have values that are not numbers, or that do not sum up to the given value. |
|
| Sets this handler to fire only if the given widget's value can be interpreted as a number. |
|
| Sets this handler to fire only if the given widget's value is one of the strings given in the options parameter. |
|
| Sets this handler to fire only if the given widget's value can be interpreted as a number and is between min and max. |
|
| Sets this handler to fire only if the given widgets have values that are numbers and sum up to the given value. |
Deprecated methods
forEventSource()
forEventSource()
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the target of this handler for subsequent directives to be whatever widget triggered the event that this handler was called for. This does not change the target for any previous directives.
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
forTargets(widgets)
forTargets(widgets)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the target of this handler for subsequent directives to be the given widgets. This does not change the target for any previous directives.
Parameters
Name | Type | Description |
---|---|---|
widgets | Object... | the widgets to target. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
getId()
getId()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the id that has been assigned to this object.
This can be used in conjunction with app.getElementById() to retrieve a reference to this object.
Return
String
— the id that has been assigned to this object
getTag()
getTag()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the text tag of this
.ClientHandler
Return
String
— the text tag.
getType()
getType()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the type of this object.
Return
String
— the object type
setEnabled(enabled)
setEnabled(enabled)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set the enabled/disabled state of the widgets this handler is targeted to. This will fail if the widgets being targeted do not support being enabled or disabled.
Parameters
Name | Type | Description |
---|---|---|
enabled | Boolean | whether the targeted widgets should be enabled. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setHTML(html)
setHTML(html)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set the html text of the widgets this handler is targeted to. This will fail if the widgets being targeted do not support having html text set.
Parameters
Name | Type | Description |
---|---|---|
html | String | the new html text for the targeted widgets. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setId(id)
setId(id)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the id of this
.ClientHandler
Parameters
Name | Type | Description |
---|---|---|
id | String | the new id, which can be used to retrieve the from
app.getElementById(id). |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setStyleAttribute(row, column, attribute, value)
setStyleAttribute(row, column, attribute, value)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set a style attribute on a grid element. This will fail if the widgets the handler is targeted to are not grids.
Parameters
Name | Type | Description |
---|---|---|
row | Integer | the row of the grid. |
column | Integer | the column of the grid. |
attribute | String | the CSS attribute to set. Use camelCase (e.g. fontSize, not font-size). |
value | String | the CSS value to set. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setStyleAttribute(attribute, value)
setStyleAttribute(attribute, value)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set a style attribute on the widgets the handler is targeted to.
Parameters
Name | Type | Description |
---|---|---|
attribute | String | the CSS attribute to set. Use camelCase (e.g. fontSize, not font-size). |
value | String | the CSS value to set. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setStyleAttributes(row, column, attributes)
setStyleAttributes(row, column, attributes)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set multiple style attributes on a grid element. This will fail if the widgets the handler is targeted to are not grids.
Parameters
Name | Type | Description |
---|---|---|
row | Integer | the row of the grid. |
column | Integer | the column of the grid. |
attributes | Object | the CSS attributes and values to set. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setStyleAttributes(attributes)
setStyleAttributes(attributes)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set multiple style attributes on the widgets the handler is targeted to.
Parameters
Name | Type | Description |
---|---|---|
attributes | Object | the CSS attributes and values to set. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setTag(tag)
setTag(tag)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the text tag of this
.ClientHandler
Parameters
Name | Type | Description |
---|---|---|
tag | String | the new text tag, which can be anything you wish to store with the widget. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setText(text)
setText(text)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set the text of the widgets this handler is targeted to. This will fail if the widgets being targeted do not support having their text set.
Parameters
Name | Type | Description |
---|---|---|
text | String | the new text for the targeted widgets. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setValue(value)
setValue(value)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set the boolean value of the widgets this handler is targeted to. This will fail if the widgets being targeted do not support having a boolean value set.
Parameters
Name | Type | Description |
---|---|---|
value | Boolean | the new value for the targeted widgets. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
setVisible(visible)
setVisible(visible)
Deprecated. This function is deprecated and should not be used in new scripts.
A directive to set the visibility of the widgets this handler is targeted to. This will fail if the widgets being targeted do not support being made invisible.
Parameters
Name | Type | Description |
---|---|---|
visible | Boolean | whether the targeted widgets should be visible. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateEmail(widget)
validateEmail(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is a valid email address.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateInteger(widget)
validateInteger(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value can be interpreted as an integer.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateLength(widget, min, max)
validateLength(widget, min, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is a string whose length is between min and max.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
min | Integer | the minimum length. If null, no minimum is enforced. |
max | Integer | the maximum length. If null, no maximum is enforced. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateMatches(widget, pattern)
validateMatches(widget, pattern)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value matches this regular expression.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
pattern | String | the regex to test, as a string. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateMatches(widget, pattern, flags)
validateMatches(widget, pattern, flags)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value matches this regular expression.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
pattern | String | the regex to test, as a string. |
flags | String | regex flags. The only valid characters in this string are 'g', 'm', and 'i'. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotEmail(widget)
validateNotEmail(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is not a valid email address.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotInteger(widget)
validateNotInteger(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value cannot be interpreted as an integer.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotLength(widget, min, max)
validateNotLength(widget, min, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is a string whose length is less than min or greater than max.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
min | Integer | the minimum length. If null, no minimum is enforced. |
max | Integer | the maximum length. If null, no maximum is enforced. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotMatches(widget, pattern)
validateNotMatches(widget, pattern)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value does not match this regular expression.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
pattern | String | the regex to test, as a string. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotMatches(widget, pattern, flags)
validateNotMatches(widget, pattern, flags)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value does not match this regular expression.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
pattern | String | the regex to test, as a string. |
flags | String | regex flags. The only valid characters in this string are 'g', 'm', and 'i'. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotNumber(widget)
validateNotNumber(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value cannot be interpreted as an number.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotOptions(widget, options)
validateNotOptions(widget, options)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is not one of the strings given in the options parameter.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
options | String[] | the list of unacceptable values |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotRange(widget, min, max)
validateNotRange(widget, min, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value cannot be interpreted as a number that is between min and max.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
min | Number | the minimum length. If null, no minimum is enforced. |
max | Number | the maximum length. If null, no maximum is enforced. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNotSum(widgets, sum)
validateNotSum(widgets, sum)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widgets have values that are not numbers, or that do not sum up to the given value.
This will cause an error if any of the widgets do not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widgets |
| an array of the widgets to validate on. |
sum | Integer | the sum to validate with |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateNumber(widget)
validateNumber(widget)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value can be interpreted as a number.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateOptions(widget, options)
validateOptions(widget, options)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value is one of the strings given in the options parameter.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
options | String[] | the list of acceptable values |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateRange(widget, min, max)
validateRange(widget, min, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widget's value can be interpreted as a number and is between min and max.
This will cause an error if the widget does not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widget |
| the widget to validate on. |
min | Number | the minimum length. If null, no minimum is enforced. |
max | Number | the maximum length. If null, no maximum is enforced. |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler
validateSum(widgets, sum)
validateSum(widgets, sum)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets this handler to fire only if the given widgets have values that are numbers and sum up to the given value.
This will cause an error if any of the widgets do not have a text property.
Parameters
Name | Type | Description |
---|---|---|
widgets |
| an array of the widgets to validate on. |
sum | Integer | the sum to validate with |
Return
— the ClientHandler
itself, useful for chaining.ClientHandler