<AppML> Case Study - Application Model


This case study demonstrates how to build a complete <AppML> Internet application with the ability to list, edit, and search information for several tables in a database.


Application Model

In this chapter, we will build a complete application model for the Customers table in the database.


<AppML> Filters

To allow filtering of <AppML> data, simply add a <filters> element to the model:

Example:

<filters>
<query>
<field label="Customer">CustomerName</field>
<field>City</field>
<field>Country</field>
</query>
<order>
<field label="Customer">CustomerName</field>
<field>City</field>
<field>Country</field>
</order>
</filters>

For a full explanation, please refer to the <AppML>Reference Manual。


<AppML> Update

To allow updating of <AppML> data, simply add an <update> element to the model:

Example:

<update>
<item><name>LastName</name></item>
<item><name>FirstName</name></item>
<item><name>BirthDate</name></item>
<item><name>Photo</name></item>
<item><name>Notes</name></item>
</update>

And add a <maintable> and a <keyfield> element to the <database> element:

Example:

<maintable>Customers</maintable>
<keyfield>CustomerID</keyfield>

For a full explanation, please refer to the <AppML>Reference Manual。


<AppML> Security

You can easily add security to an <AppML> model by adding a security attribute to the <AppML> tag.

Example:

<appml security="admin">

In the example above, only users who log in as members of the user group "admin" can access the model.

To set security for the <update> element, simply add a security attribute to the <update> element:

Example:

<update security="admin">
<item><name>LastName</name></item>
<item><name>FirstName</name></item>
<item><name>BirthDate</name></item>
<item><name>Photo</name></item>
<item><name>Notes</name></item>
</update>


Complete Customers Model

In this chapter, we will set up an application model for each table in the database.

Create a new folder named Models. In the Models folder, create a model for each application.

Model: Customers.xml

<appml security="">

<datasource>
<database>
<connection>Demo</connection>
<maintable>Customers</maintable>
<keyfield>CustomerID</keyfield>
<sql>SELECT * FROM Customers</sql>
<orderby>CustomerName,City,Country</orderby>
</database>
</datasource>

<filters>
<query>
<field label="Customer">CustomerName</field>
<field>City</field>
<field>Country</field>
</query>
<order>
<field label="Customer">CustomerName</field>
<field>City</field>
<field>Country</field>
</order>
</filters>

<update security="admin">
<item><name>CustomerName</name></item>
<item><name>ContactName</name></item>
<item><name>Address</name></item>
<item><name>PostalCode</name></item>
<item><name>City</name></item>
<item><name>Country</name></item>
</update>

</appml>



Model View

Create a model view, save it as Demo_Model.html, and try it out:

View: Demo_Model.htm

<h1>Customers</h1>
<div id="List01"></div>

<script src="appml.js.html"></script>
<script>
customers=new AppML("appml.htmlx","Models/Customers");
customers.run("List01");
</script>

Try it yourself »


Now Combine Everything Together

Then, with a little JavaScript coding, create a test page for all models:

Demo_Model_Views.htm

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="appml.css.html" />
</head>

<body>
<h1>Demo Applications</h1>

<button onclick='myOpen("Customers")'>Customers</button>
<button onclick='myOpen("Products")'>Products</button>
<button onclick='myOpen("Suppliers")'>Suppliers</button>
<button onclick='myOpen("Shippers")'>Shippers</button>
<button onclick='myOpen("Categories")'>Categories</button>
<button onclick='myOpen("Employees")'>Employees</button>
<button onclick='myOpen("Orders")'>Orders</button>
<button onclick='myOpen("OrderDetails")'>OrderDetails</button>
<br><br>

<div id="Place01"></div>

<script src="appml.js.html"></script>
<script>
function myOpen(pname)
{
var app_obj
app_obj=new AppML("appml.php","Models/" + pname);
app_obj.run("Place01");
}
</script>

</body>
</html>

Show Results »


Other Extensions