<AppML> Étude de cas - Modèles HTML
Cette étude de cas montre comment créer une application Internet <AppML> complète avec la possibilité de lister, modifier et rechercher des informations pour plusieurs tables dans une base de données.
Ajouter des modèles HTML
Dans ce chapitre, nous allons montrer comment ajouter des modèles HTML à une page HTML.
Liste des clients
HTML - Vue
<h1>Clients</h1>
<div id="List01"></div><br>
<table id="Template01" class="appmltable" style="display:none">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
</script>
<div id="List01"></div><br>
<table id="Template01" class="appmltable" style="display:none">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
</script>
Essayez-le vous-même »
Liste des clients et formulaires clients
En utilisant intelligemment les modèles, il est facile d'ajouter des liens entre les objets de liste <AppML> et les formulaires <AppML> :
HTML - Vue
<h1>Clients</h1>
<div id="Form01"></div><br>
<div id="List01"></div><br>
<table id="Template01" class="appmltable" style="width:100%;display:none">
<tr>
<th></th>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
</tr>
<tr id="appml_row">
<td style="cursor:pointer" onclick="openForm('#CustomerID#')">
<img src="images/appmlFolder.png.html"></td>
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers,customerForm;
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
function openForm(id)
{
customerForm=new AppML("appml.php","Models/Customers");
customerForm.displayType="form";
customerForm.run("Form01","",id);
}
</script>
<div id="Form01"></div><br>
<div id="List01"></div><br>
<table id="Template01" class="appmltable" style="width:100%;display:none">
<tr>
<th></th>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
</tr>
<tr id="appml_row">
<td style="cursor:pointer" onclick="openForm('#CustomerID#')">
<img src="images/appmlFolder.png.html"></td>
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers,customerForm;
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
function openForm(id)
{
customerForm=new AppML("appml.php","Models/Customers");
customerForm.displayType="form";
customerForm.run("Form01","",id);
}
</script>
Essayez-le vous-même »
Liste des clients et des commandes clients
En utilisant astucieusement les modèles, il est facile d'ajouter des liens entre les objets de liste <AppML> et les listes liées :
HTML - Vue
<h1>Clients</h1>
<div id="List01"></div><br>
<div id="Orders01"></div><br>
<table id="Template01" class="appmltable" style="width:100%;display:none">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
<th></th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
<td><a href='' onclick='openOrders("#CustomerID#");return false;'>Commandes</a></td>
</tr>
</table>
<table id="Template02" class="appmltable" style="width:100%;display:none">
<tr>
<th>Cliente</th>
<th>Date</th>
<th>Commercial</th>
<th>Transporteur</th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#OrderDate#</td>
<td>#Salesperson#</td>
<td>#ShipperName#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers,orders;
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
function openOrders(id)
{
orders=new AppML("appml.php","Models/Orders");
orders.setQuery("orders.customerid",id);
orders.commands=false;
orders.run("Orders01","Template02");
}
</script>
<div id="List01"></div><br>
<div id="Orders01"></div><br>
<table id="Template01" class="appmltable" style="width:100%;display:none">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
<th></th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
<td><a href='' onclick='openOrders("#CustomerID#");return false;'>Commandes</a></td>
</tr>
</table>
<table id="Template02" class="appmltable" style="width:100%;display:none">
<tr>
<th>Cliente</th>
<th>Date</th>
<th>Commercial</th>
<th>Transporteur</th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#OrderDate#</td>
<td>#Salesperson#</td>
<td>#ShipperName#</td>
</tr>
</table>
<script src="appml.js.html"></script>
<script>
var customers,orders;
customers=new AppML("appml.php","Models/Customers");
customers.run("List01","Template01");
function openOrders(id)
{
orders=new AppML("appml.php","Models/Orders");
orders.setQuery("orders.customerid",id);
orders.commands=false;
orders.run("Orders01","Template02");
}
</script>
Essayez-le vous-même »
Maintenant, combinez tout ensemble
Enfin, avec un peu de duplication de code, nous pouvons terminer le projet.
Liste des clients, formulaires et commandes
<h1>Clients</h1>
<div id="List01">
<table id="appml_list" class="appmllist">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
<th></th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
<td><a href='' onclick='openOrders("#CustomerID#");return false;'>Commandes</a></td>
</tr>
</table>
</div>
<div id="List02"></div>
<script src="appml.js.html"></script>
<script>
var Customers,Orders
Customers=new AppML("appml.php","Models/Customers");
Customers.run("List01");
function openOrders(id)
{
var Orders=new AppML("appml.php","Models/Orders");
Orders.setQuery("orders.customerid",id);
Orders.commands=false;
Orders.run("List02");
}
</script>
<div id="List01">
<table id="appml_list" class="appmllist">
<tr>
<th>Cliente</th>
<th>Città</th>
<th>Paese</th>
<th></th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
<td><a href='' onclick='openOrders("#CustomerID#");return false;'>Commandes</a></td>
</tr>
</table>
</div>
<div id="List02"></div>
<script src="appml.js.html"></script>
<script>
var Customers,Orders
Customers=new AppML("appml.php","Models/Customers");
Customers.run("List01");
function openOrders(id)
{
var Orders=new AppML("appml.php","Models/Orders");
Orders.setQuery("orders.customerid",id);
Orders.commands=false;
Orders.run("List02");
}
</script>
Essayez-le vous-même »
Dans les chapitres suivants, vous pouvez voir plus d'applications avec le code source complet.
Autres extensions