Monday, 2 April 2018

Kony-Local Storage NameSapce API Elements


Kony-Local Storage API Elements

Syntax :-
  1. kony.store.setItem(key, value)
  
       key [string] - Mandatory

             Specifies the keyname for which the item needs to be set

    value [object] - Mandatory
              Specifies the value that must be set at the given index. This value can be a number, 
             string,Boolean    

 Example : 

         kony.store.setItem("keyValue5", "this is a key value"); //string
         kony.store.setItem("keyValue4", true); //boolean

     
kony.store.getItem(keyname)

       Specifies the keyname from which the item needs to be fetched.
Example :
     
     var myValue = kony.store.getItem("name");
     alert("name is "+myValue);
  
kony.store.removeItem(keyname)
  
       Specifies the keyname for which the item needs to be removed.

Example :        

        kony.store.removeItem("name");
        alert("name removed");
   
kony.store.clear()

    clearing all the key-value pairs   
  
kony.store.key(index)
  
       Specifies the index for which the key name is to be returned.   

Example :
    
       var keyName = kony.store.key(0);
       alert("first key name is "+keyName);

kony.store.length()

    Returns the length of the local storage.
 





 

Kony-Alert Example

Kony-Alert Sample Code




Syntax :-
            kony.ui.Alert(basicConfig, pspConfig);
Parameters
basicConfig
             basicConfig is an object with the following configuration properties:
  • message [String] - Mandatory: The message to be shown when an alert is thrown.
  • alertType [Number] - Mandatory: Denotes the type of the alert. The possible values are as follows:
    • ALERT_TYPE_CONFIRMATION
    • ALERT_TYPE_ERROR
    • ALERT_TYPE_INFO
  • alertTitle [String] - Optional: Title of the alert.
  • yesLabel [String] - Optional: Text to be displayed for the Yes label. If the text for the Yes label is not provided, individual platforms display default values.
  • noLabel [String] - Optional: Text to be displayed for the No label. If the text for the No label is not provided, individual platforms display default values.
  • alertIcon [String / image Object] - Optional: Icon to be displayed to visually indicate the type of alert, such as, Info, Error, Confirmation. This parameter is not supported on iPhone. You can create an image Object by using kony.image Namespace functions.
  • alertHandler [Read / Write Event] - Mandatory: JavaScript function that should get called when alert is dismissed either through "yes" label button or through "no" label button.
pspConfig
             pspConfig is an object with platform specific configuration properties.
             ondeviceback [Write Event] - Optional: JavaScript function that should get called when alert is open and the device back button is pressed.

Example Code:-

function showINFOALERT() {
    try {
        var pspConfig = {
            "iconPosition": constants.ALERT_CONTENT_ALIGN_CENTER,
            "contentAlignment": constants.ALERT_ICON_POSITION_LEFT
        };

        var alert = kony.ui.Alert({
            "message": "Hello Alert", //optional
            "alertType": constants.ALERT_TYPE_INFO,
            "alertTitle": "I'm Alert",
            "yesLabel": "Yes",
            "noLabel": "",
            "alertIcon": "",
            "alertHandler": null
        }, pspConfig);

    } catch (err) {
        alert(err);
    }
}



Output Screen :- INFO







Without title (Optional) :- INFO



Example 2 : Confirm Alert :-


function showConfirmALERT() {
    try {
        var pspConfig = {
            "iconPosition": constants.ALERT_CONTENT_ALIGN_CENTER,
            "contentAlignment": constants.ALERT_ICON_POSITION_LEFT
        };

        var alert = kony.ui.Alert({
            "message": "Hello Alert",
            "alertType": constants.ALERT_TYPE_CONFIRMATION,
            "alertTitle": "sample alert",
            "yesLabel": "Yes",
            "noLabel": "No",
            "alertIcon": "",
            "alertHandler": null
        }, pspConfig);
    } catch (err) {
        alert(err);
    }
}



Output Screen :-




A failure occurred while executing com.android.build.gradle.tasks

Error in Kony visualizer V9 service pack 6 and FX11  [2023-01-09 22:23:32.695] [DEBUG] ~~~~ - INFO [exec-shell] Execution failed for task ...