X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

<AppML> Case Study - Application Models


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


Application Models

In this chapter we will set up a full 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>

Look at the <AppML> Reference for a full overview.


<AppML> Update

To allow update 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 a <maintable> and <keyfield> element to the <database> element: 

Example:

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

Look at the <AppML> Reference for a full overview.


<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 logged in as a member 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>


Full Customers Model

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

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

Model: Customers.xml

<appml security="">

<datasource>
<database>
  <connection>AppmlDemo</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 Views

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

View: Demo_Model.htm

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

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

Try it yourself »


All Together Now

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" />
</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.aspx","Models/" + pname);
app_obj.run("Place01");
}
</script>

</body>
</html>

Show it »



Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook