<AppML> Case Study - Prototype
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.
Prototype
In this chapter, we will create a prototype model for each table in the database.
Prototypes are a very convenient starting point for developing applications.
Prototype Models
First, create a folder for the prototypes. Name this folder Prototypes.
Then, create a prototype model for each table in the database.
Use SELECT * from each table, and save the models as XML files:
Model: Proto_Customers.xml
<appml>
<datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Customers</sql>
</database>
</datasource>
</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>
<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>
<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:
View: Demo_Prototype.htm
<h1>Customers</h1>
<div id="List01"></div>
<script src="appml.js.html"></script>
<script>
customers=new AppML("appml.php","Prototypes/Customers");
customers.run("List01");
</script>
<div id="List01"></div>
<script src="appml.js.html"></script>
<script>
customers=new AppML("appml.php","Prototypes/Customers");
customers.run("List01");
</script>
Try it »
Now combine everything together
Finally, with a little JavaScript coding, create a simple prototype page for all prototype models:
Demo_Prototype_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","Prototypes/" + pname);
app_obj.run("Place01");
}
</script>
</body>
</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","Prototypes/" + pname);
app_obj.run("Place01");
}
</script>
</body>
</html>
Show results »
Other Extensions