Plugins:ClientStorage
last edited by
lmajano
on 15-Apr-2010
|
Exploring the ClientStorage Plugin
Overview
Client Storage plugin. It provides the user with a mechanism for permanent data storage using the client scope and WDDX.
clearAll
Clear the entire coldbox client storage
Returns
- This function returns void
Examples
// Clear the entire client storage getPlugin("ClientStorage").clearAll();
exists
Checks wether the permanent variable exists.
Returns
- This function returns boolean
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
Examples
if ( getPlugin("ClientStorage").exists("userData") ){ // use the data }
getVar
Get a new permanent variable. If the variable does not exist. The method returns blank.
Returns
- This function returns any
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
| default | any | No | The default value to set. If not used, a blank is returned. |
Examples
// No default var userData = getPlugin("ClientStorage").getVar("userData"); // With Default var data= getPlugin("ClientStorage").getVar("userData", structNew() );
setVar
Set a new permanent variable.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The name of the variable. |
| value | any | Yes | --- | The value to set in the variable. |
Examples
// Prepare data, can be simple or complex userData = { name = "Luis Majano", created = now(), nicknames = ["Captain Awesome", "Pio"], awesomeLevel = "high" }; getPlugin("ClientStorage").setVar("userData", userData);
getStorage
Get the entire storage scope structure
Returns
- This function returns struct
Examples
var clientStorage = getPlugin("ClientStorage").getStorage();
deleteVar
Tries to delete a permanent client var.
Returns
- This function returns boolean
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
Examples
getPlugin("ClientStorage").deleteVar("userData");

SideBar
User Login 




Comments (