Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

Application Module

The Application Module is to adjust the running state of RhoElements applications.

Syntax

application (Module) <META> Syntax

<META HTTP-Equiv="Application" content="[method]">

Application JavaScript Object Syntax:
By default the JavaScript Object 'application' will exist on the current page and can be used to interact directly with the application.
To Invoke application methods via JavaScript use the following syntax: application.method();

e.g. application.quit();
To Set application return events via JavaScript use the following syntax: application.event = JavaScript Function;

e.g. application.applicationEvent = 'doFunction(%json)';

For more details on the event syntax and parameters see the Retrieval Events page.
To set multiple EMML parameters / events on a single line use the following syntax: application.setEMML("[Your EMML Tags]");

e.g. application.setEMML("applicationEvent:url('JavaScript:doFunction(%json)');quit");
Application Ruby Object Syntax:
By default the Ruby Object 'Application' will exist on the current page and can be used to interact directly with the Application. All Methods, Parameters and Events are the same as JavaScript, however, notice 'Application' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()'
To Invoke Application methods via Ruby use the following syntax: Application.method()

e.g. Application.quit
To Set Application return events via Ruby use the following syntax: Application.event = url_for(:action => :event_callback)

e.g. Application.applicationEvent = url_for(:action => :application_event_callback)

For more details on the event syntax and parameters see the Retrieval Events page.

To access the event parameters in a Ruby callback function, you reference the @params object within the callback function. This object is simply a ruby hash {"parameter1 name" => "parameter1 value", "parameter2 name" => "parameter2 value", ...}

Methods

Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.

Name Description Default Value
quit Quits RhoElements N/A
minimize Minimizes RhoElements N/A
restore Restores RhoElements to full screen N/A
getVersion Returns the version of all installed components via a 'VersionEvent' N/A

Events

Values are returned to the caller in RhoElements via Events. Most modules contain events and those returned from this module are given below along with the event parameters. Events can cause a navigation to a new URL or a JavaScript function on the page to be invoked. Each event will in most cases have a number of parameters associated with it which will either be strings or JavaScript arrays. Event parameters can be accessed either directly or via JSON objects.


applicationEvent

The ApplicationEvent is triggered when a RhoElements application is minimized or restored.

ID Name Description
1 applicationState "Minimized" or "Restored"

versionEvent

The version of RhoElements installed on the device

ID Name Description
1 productVersion A string defining the released version running on the device, this will be in the form v.w.x.y. E.g. 1.0.0.0
2 hotFixes A JavaScript array of strings containing the hot fixes applied. There may have been multiple hot fixes applied, e.g. ['1','3']
3 componentVersions (module, version) A 2 dimensional array of strings which defined a mapping between each of the installed plugins' name and their version. See remarks

Remarks

ComponentVersions Array Format

The ComponentVersions parameter in the VersionEvent is defined as a 2D array:


(
   (            //  Array for Component 1
      module,   //  The name of the module (string).
      version,  //  The version of the module (string) in the form v.w.x.y.z.
   )
   (            //  Array for Component 2
      module,
      version,
   )
)

Requirements

RhoElements Version 1.0.0 or above
Supported Devices All supported devices except: Enterprise Tablet - does not support "Restore" method.
Minimum Requirements None.
Persistence Immediate - These methods are actioned immediately.

HTML/JavaScript Examples

The following example causes RhoElements to exit when the page is loaded

<META HTTP-Equiv="Application" Content="Quit">

The following example minimizes RhoElements when the enter key is pressed and reports its state in a message box

<META HTTP-EQUIV="OnKey0x0d" content="javascript:doTest();">
<META HTTP-EQUIV="Application" content="ApplicationEvent:url('JavaScript:receivedEvent('%s');')">

<SCRIPT>
    function doTest()
    {
        application.minimize();
    }
    function doEvent(currentState)
    {
        alert('RhoElements has been ' + currentState);
    }
</SCRIPT>

The following example

<META HTTP-EQUIV="Application" content="VersionEvent:url('javascript:fnVerJSON(%json);')">

<SCRIPT>
    function fnVerJSON(jsonObject)
    {
        var theOutput = "<B>Product Version:</b> " + jsonObject.productVersion + "<P>";
        theOutput = theOutput + "<b>Hot Fixes:</b><P>";
        for (var i=0; i<jsonObject.hotFixes.length; i = i + 1)
        {
            theOutput = theOutput + "  Hot Fix: " + jsonObject.hotFixes[i] + "<BR>";
        }
        theOutput = theOutput + "<P>";
        theOutput = theOutput + "<b>Installed Components:</b><P>";
        for (var j=0; j<jsonObject.componentVersions.length; j = j + 1)
        {
            theOutput = theOutput + "  Module: " + jsonObject.componentVersions[j].module + ', Version: ' + jsonObject.componentVersions[j].version + "<BR>";
        }
        outputDiv.innerHTML = theOutput;
    }
</SCRIPT>
<div id="outputDiv">Version Goes Here</div>
<P>
  <INPUT align="center" type="button" value="Retrieve Version" onclick="application.getVersion()"><br>
Back to Top