WaveMaker Docs

WaveMaker Docs

  • Get started
  • Widgets
  • Mobile
  • How-to
  • Enterprise
  • Releases
  • Blog
  • Sign-in

›Variables

Getting started

  • Introduction
  • Walkthrough

Pages

  • Pages Overview
  • Creating a Page
  • Layout and Styles

    • Page Layout
    • Templates
    • Themes
    • Accessibility

    Page Configure

    • Page Artefacts
    • Page Cache
    • Partial Page
    • Page Parameters
    • Examples

    Page Actions

    • Navigation
    • Events

    Custom Development

    • Theme Editor
    • Manual Theme
    • Create Template

SSPA

  • Micro Frontend App

Databases

  • Database Services Overview
  • Database Tools
  • Database Designing

    • Working with Databases
    • Data Modelling
    • DataBase Schema Modes
    • Working with DB Schema
    • Database Views
    • Temporal Support

    Accessing Database

    • Accessing Database

    Queries and Procedures

    • Working with Queries
    • Working with Stored Procedures
    • Version Queries & Procedures
    • Blob Queries and Procedures
    • Queries & Procedures - Java Services

    Database Variables & API

    • Database CRUD
    • CRUD Event Listeners
    • Database APIs
    • Database Service APIs

REST & SOAP

  • Web Services Overview
  • Restful

    • REST Services
    • Secure Server-side Properties
    • REST Request Timeouts
    • REST Services using OAuth 2.0

    SOAP

    • Working with SOAP Services
    • Imported SOAP APIs

    Websocket

    • Working with WebSockets

    APIs

    • API Designer
    • Mocking APIs
    • Mocking REST API
    • Swagger Import

    Variables

    • CRUD Variable
    • Service Variable
    • WebSocket Variable

Java Services

  • Java Service
  • Java Services

    • Java Integration Services
    • DB Service Integration
    • API Composition
    • Variables for Invocation
    • Generated REST APIs (API Designer)

    Java Services Variables & API

    • Variable for Java Service
    • Java Service APIs

    Source Files

    • Resources and Third-party Libraries
    • Using 3rd party JavaScript files
    • Using 3rd party jar files

Variables & Actions

    Variables

    • Variables Overview
    • Model Variable
    • Device Variables

    Binding

    • Variable Binding
    • Custom Formatter

    Actions

    • Actions
    • Navigation Action
    • Login Action
    • Logout Action
    • Timer Action
    • Notification Action

    Events

    • Events
    • JavaScript Access

Security

    App Security

    • Overview
    • Authentication
    • Authorization
    • Access Levels & Permissions
    • Login Configuration
    • Session Persistence
    • SSL Encryption
    • XSS antisamy policy configuration
    • OWASP
    • XSS Prevention
    • Central Authentication System
    • Token Based Authentication
    • SAML Integration
    • Secure Connection for Deployed Apps
    • Concurrent Sessions
    • HostHeader Injection

    Security Variable and API

    • Security Variables
    • Remember Me
    • Variable for Security Service
    • Security Service APIs

Developer options

  • Test and Run (Preview) Apps
  • Chrome Extension: Devtool
  • Debugging
  • Inspection Framework
  • Build Options
  • WaveMaker Mobile Apps Automation
  • Developer Integration

    • Project User Management
    • Developer Collaboration
    • Extending the Application using IDEs
    • Import, Export & Update Apps
    • Project Shells

    Add-ons

    • Localization
    • Artifacts Repository

Deployment

  • Overview
  • Deployment Profile
  • One-click Deployment
  • WaveMaker CI/CD Pipeline

    • Overview
    • Configuration Profiles
    • Configuration Management
    • Pipelines and Phases

    Pipeline Configuration

    • Default Pipelines in WMO
    • Configure Pipeline in WME

    Deploy to Cloud Providers

    • AWS
    • Azure
    • Google Cloud
    • DigitalOcean

    Pipeline Configuration cont.

    • Phase configurations
    • Webhooks Integration
    • Tests Integration

    Manage Deployed Apps

    • Manage Deployed Apps

    Integrate with your CI/CD Providers

    • Push Code to External repo
    • Custom VCS Integration
    • Export WaveMaker Application
    • Building Project with Maven
    • Build with Docker
    • Jenkins Integration
    • Deploy using Docker Compose
    • Deployment to Heroku

    WaveMaker apps Interation with CDN

    • App Integration with AWS CDN
    • App Integration with Azure CDN

    Deployment to external web servers

    • Application Server Overview
    • Deploy to Tomcat
    • WebSphere
    • JBoss - WildFly
    • WebLogic Server

Connectors

  • Introduction
  • Architecture
  • Import Connectors
  • List of Connectors
  • Build a New Connector

Teams

  • Overview
  • Team Setup
  • Dashboard
  • Manage Users
  • Manage Projects
  • Manage Prefabs
  • Project Branches
  • Manage Roles
  • Code Repository
  • Import VCS Project
  • Team Profile
  • Manage Subscription
  • FAQs
Edit

Model Variable


Model Variable can be used as storage model to store data on the client.

These Variable store data on the page or at the project level. The data can be of various types:

  • Boolean value
  • Date value
  • Entry for name-value pairs
  • Number value
  • String value
  • Database table object
  • Service API request or response object

Each of these types can further be in an array format by selecting the isList property.

Variable Creation

The data source for these Variables is custom-defined.

  1. Select the Variable option from the Variable Workspace Toolbar.

  1. Click New Variable from the Variable Dialog

  1. This will initiate Create Variable wizard.

Steps in Variable Wizard

  1. Select Model as the target action
  2. Select the Type based upon the type of data you want the Static variable to hold.
  3. Based on the selection, the JSON structure will change
    • for default types of boolean, number, string, date types you will be allowed to enter the values
    • for entry type, you can enter the name-dataValue pair
    • prebuilt variables gives a pre-populated variable structure - these include country, days, month, and US states list
    • for any service types selected, will give you the respective table object structure or request parameters or response format structure
  4. Setting the Is List property will allow you to create an array structure of the type selected
  5. You can choose to add values using the text editor instead of field editor
  6. Data tab will let you set the values dynamically by binding it to a widget or another variable. For example, you can capture the data from a Live Form into an app-level static variable and use it in a different page
  7. You will be directed to the Variables page, with the new variable listed. As you can see:
    1. a Model Variable is created,
    2. the properties tab contains all the properties. Know more about properties.
    3. the data tab will contain the fields serving as input fields for the Variable

Properties

Static Variables help you store page or application level data. Using Static Variable you can even store data as cookies.

PropertyDescription
TypeProperty to use to specify the data-type of the static variable. This includes live/service variables also.
Is ListProperty to use if the data in the variable is of type array.
JSON
name (for Entry type)Name of the data value in the name-datavalue pair
Data ValueProperty to specify the value to be stored in the variable. You can use either the Field Editor or Text Editor to specify the values.

Methods

getDatasetDataclearDatagetValuesetValue
getItemsetItemaddItemremoveItemgetCount

getData()

This method returns the variable’s dataSet.

Parameters: none

Return Value: If the variable is of list type then returns an Array else it returns an Object

Example:

var result = Page.Variables.staticVariable1.getData();
console.log("result:", result);

// Output: 
// result: {dataValue: “abc”}

setData(object)

This method sets the passed data on the dataSet property of the Variable.

Parameters: Object or Array

Return Value: Newly set dataSet on the variable

Example:

var result = Page.Variables.staticVariable1.setData({dataValue: “def”});
console.log("result:", result);

// Output: 
// result: {dataValue: “def”}

getValue(key)

This method returns the value against the specified key. If dataSet is an array returns the value against the specified key of the object at the specified index.

Parameters:

  • key(string):
  • index(number): required in case the static variable is an array

Return Value: Value against the key

Example:

// Example 1: If variable is having dataSet as: {dataValue: “abc”}
var result = Page.Variables.staticVariable1.getValue(‘dataValue’);
console.log("result:", result);

// Output: 
// result: “abc”

// Example 2: If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.getValue(‘dataValue’, 1);
console.log("result:", result);

// Output: 
// result: “def”

setValue(key, value)

This method sets the value against the specified key.

Parameters:

  • key(string)
  • value(*)

Return Value: Updated dataSet of variable

Example:

// Example1: If variable is having dataSet as: {dataValue: “abc”}
var result = Page.Variables.staticVariable1.setValue(‘dataValue’, “def”);
console.log("result:", result);

// Output: 
// result: {dataValue: “def”}

// Example 2: using key parameter. If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.setValue('key’, “ghi”);
console.log("result:", result);

// Output: 
// result: {dataValue: “def”, key: “ghi”}

getItem(index)

This method returns the object against the specified index.

note

This is only for array type variable, i.e. when the Is List property is set.

Parameters: index(number)

Return Value: Object

Example:

// If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.getItem(1);
console.log("result:", result);

// Output: 
// result: {dataValue: “def”}

setItem(index, value)

This method sets the value against the specified index.

note

Only for array type variable, i.e. when the Is List property is set.

Parameters:

  • index(number)
  • value(*)

Return Value: Updated dataSet of variable

Example:

// If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.setItem(1, {dataValue: "jkl"});
console.log("result:", result);

// Output: 
// result: [{dataValue: “abc”}, {dataValue: “jkl”}, {dataValue: “ghi”}]

addItem(value, index)

This method adds an item at specified index.

note

Only for array type variable, i.e. when the Is List property is set.

Parameters:

  • index(number)
  • value(*)

Return Value: Updated dataSet of variable

Example:

//Example1: If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.addItem({dataValue: "jkl"});
console.log("result:", result);

// Output: 
// result: [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}, {dataValue: “jkl”}]

//Example2: If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.addItem({dataValue: "jkl"}, 1);
console.log("result:", result);

// Output: 
// result: [{dataValue: “abc”}, {dataValue: “jkl”}, {dataValue: “def”}, {dataValue: “ghi”}]

removeItem(index)

This method updates the dataSet of variable

note

Only for array type variable, i.e. when the Is List property is set

Parameters: index(number)

Return Value: Updated dataSet of variable

Example:

// If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.removeItem(1);
console.log("result:", result);

// Output: 
// result: [{dataValue: “abc”}, {dataValue: “ghi”}]

clearData()

This method empties the variable dataSet.

note

Only for array type variable, i.e. when the Is List property is set.

Parameters: none

Return Value: Updated dataSet of variable

Example:

// If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.clearData();
console.log("result:", result);

// Output: 
// result: []

getCount()

This method returns the total number of items in the dataSet.

note

Only for array type variable, i.e. when the Is List property is set.

Parameters: none

Return Value: Number of items

Example:

// If variable is list type having data as:
// [{dataValue: “abc”}, {dataValue: “def”}, {dataValue: “ghi”}]
var result = Page.Variables.staticVariable1.getCount();
console.log("result:", result);

// Output: 
// result: 3
Last updated on 12/16/2019 by PriyankaPathoori
← Variables OverviewDevice Variables →
  • Variable Creation
    • Steps in Variable Wizard
  • Properties
  • Methods
    • getData()
    • setData(object)
    • getValue(key)
    • setValue(key, value)
    • getItem(index)
    • setItem(index, value)
    • addItem(value, index)
    • removeItem(index)
    • clearData()
    • getCount()
WaveMaker
  • PRICING
  • PARTNERS
  • CUSTOMERS
  • ABOUT US
  • CONTACT US
Terms of Use | Copyright © 2013-2023 WaveMaker, Inc. All rights reserved.