API AppML


L'API AppML definisce i metodi e le proprietà di AppML


Cosa possono fare i metodi e le proprietà?

Con metodi e proprietà puoi:

  • Crea applicazioni AppML
  • Alimenta le applicazioni con i dati
  • Recupera i dati dell'applicazione da utilizzare nella tua pagina web

Esempio

new AppML() crea un nuovo oggetto AppML.
dataSource
imposta l'origine dati dell'oggetto AppML.
getData()
ottiene i dati.
data.records
contiene i record di dati.

Puoi scorrere i record e visualizzare il contenuto in un elemento HTML:

Esempio

// Create an AppML object and fetch the data
myObj = new AppML();
myObj.dataSource = "https://www.w3schools.com/appml/customers.php";
myObj.getData();

// Locate the data records
myArr = myObj.data.records;
len = myArr.length;

// Display the records
for (i = 0; i < len; i++) {
    txt += myArr[i].CustomerName + "<br>";
}
document.getElementById("demo").innerHTML = txt;

Risultato

Alfreds Futterkiste
Berglunds snabbköp
Centro comercial Moctezuma
Ernst Handel
FISSA Fabrica Inter. Salchichas S.A.
Galería del gastrónomo
Island Trading
Königlich Essen
Laughing Bacchus Wine Cellars
Magazzini Alimentari Riuniti
North/South
Paris spécialités
Rattlesnake Canyon Grocery
Simons bistro
The Big Cheese
Vaffeljernet
Wolski Zajazd

Alcuni metodi AppML

Method Description
new AppML() Creates a new AppML object
run() Runs an application object
appml("name") Returns the appml object with the specified name
displayMessage(text) Displays a specified message.
setError(no, description) Sets a specified error and error description.

Alcune proprietà di AppML

Property Description
appName The application name (the container id)
container The application container element
controller The application controller
data The application data object
dataSource The application data source
message The application message

Alcune proprietà degli oggetti dati

Property Description
data.model The application data model
data.records The application data records