AppML case prototype



This case study demonstrates how to build a complete <AppML> Internet application with capabilities for listing, editing, and searching information across several tables in a database.


Prototype

In this chapter, we will build a prototype model for each table in the database.

Prototypes are a very user-friendly starting point for developing applications.


Prototype Model

First, create a folder for the prototype. The folder is named Prototypes.

Then, create a prototype model for each table in the database.

Use SELECT * from each table and save the model as an XML file:

Model: Proto_Customers.xml

<appml>
< datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Customers</sql>
</database>
</datasource>
</appml>

Model: Proto_Suppliers.xml

<appml>
< datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Suppliers</sql>
</database>
</datasource>
</appml>

Model: Proto_Products.xml

<appml>
< datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Products</sql>
</database>
</datasource>
</appml>



##Prototype View

Create a prototype view, save it as Demo_Prototype.html, and try it out:

Example

视图:Demo_Prototype.htm
<h1>Customers</h1>
<div id="List01"></div>

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

Run Example»Click "Run Example" button to view the online example


Now to merge it all together

Finally, with a little JavaScript coding, create a simple prototype page for all prototype models :

Instance

Demo_Prototype_Views.htm
            <!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="appml.css" />
</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"></script>
<script>
function myOpen(pname)
{
var app_obj
app_obj=new AppML("appml.php","Prototypes/" + pname);
app_obj.run("Place01");
}
</script>

</body>
</html>

Run instance»Click the "Run instance" button to view the online instance