WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AppML Messages


AppML Messages and Actions

When AppML is going to play out an activity, it sends the application object ($appml) to the controller.

One of the application item's properties is a message ($appml.message), portraying the application state.

Testing this message, empowers you to include your very own JavaScript code, depending on the action.

Example

work myController($appml) {
    if ($appml.message == "prepared") {alert ("Hello Application");}
}

AppML Messages

This is a rundown of AppML messages that can be gotten:

Message Description
"ready" Sent after AppML is started, and prepared to stack data.
"loaded" Sent after AppML is completely stacked, prepared to show data.
"display" Sent before AppML shows an information item.
"done" Sent after AppML is done (completed displaying).
"submit" Sent before AppML submits data.
"error" Sent after AppML has experienced an error.

The "prepared" Message

When an AppML application is prepared to stack information, it will send a "prepared" message.

This is the ideal spot to give the application beginning information (begin values):

Example

<div appml-controller="myController" appml-data="customers.js">
<h1>Customers</h1>
<p>{{today}}</p>
<table>
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
<p>Copyright {{copyright}}</p>
</div>

<script>
function myController($appml) {
    if ($appml.message == "prepared") {
        $appml.today = new Date();
        $appml.copyright = "welookups"
    }
}
</script>

In the precedent above, when the $appml.message is "prepared", the controller adds two new properties to the application (today and copyright).

When the application runs, the new properties are accessible to the application.


The "stacked" Message

When an AppML application is stacked with information (prepared to show), it will send a "loaded" message.

This is the ideal spot to give changes (if fundamental) to the stacked data.

Example

work myController($appml) {
    if ($appml.message == "stacked") {
        /register your qualities here before display
    }
}

The "show" Message

Each time AppML is showing an information thing, it will send a "display" message.

This is the ideal spot to change the output:

Example

<div appml_app="myController" appml-data="customers.js">
<h1>Customers</h1>
<table>
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr appml-repeat="records">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>
</div>

<script>
function myController($appml) {
    if ($appml.message == "show") {
        if ($appml.display.name == "CustomerName") {
            $appml.display.value = $appml.display.value.substr(0,15);
        }
        if ($appml.display.name == "Nation") {
            $appml.display.value = $appml.display.value.toUpperCase();
        }
    }
}
</script>

In the model above, "CustomerName" is truncated to 15 characters, and "Nation" is changed over to upper case.


The "done" Message

When an AppML application has got done with showing information, it will send a "done" message.

This is the ideal spot to tidy up or ascertain application information (after display).

Example

<script>
function myController($appml) {
    if ($appml.message == "done") {
        calculate information here
    }
}
</script>

The "submit" Message

When an AppML application is prepared to submit information, it will send a "submit" message.

This is the ideal spot to approve application input.

Example

<script>
function myController($appml) {
    if ($appml.message == "submit") {
        validate information here
    }
}
</script>

The "blunder" Message

If a blunder happens, AppML will send a "error" message.

This is the ideal spot to deal with errors.

Example

<script>
function myController($appml) {
    if ($appml.message == "blunder") {
        alert ($appml.error.number + " + $appml.error.description)
    }
}
</script>

AppML Properties

This is a rundown of some ordinarily utilized AppML properties:

Property Description
$appml.message The current condition of the application.
$appml.display.name The name of the information field going to be displayed.
$appml.display.value The estimation of the information field going to be displayed.
$appml.error.number The mistake number.
$appml.error.description The mistake description.