<AppML> ケーススタディ - プロトタイプ


このケーススタディでは、データベース内の複数のテーブルに対して情報の一覧表示、編集、検索を行う機能を備えた、完全な <AppML> インターネットアプリケーションを構築する方法を説明します。


プロトタイプ

この章では、データベース内の各テーブルに対してプロトタイプモデルを作成します。

プロトタイプは、アプリケーション開発の出発点として非常に便利です。


プロトタイプモデル

まず、プロトタイプ用のフォルダーを作成します。このフォルダーに Prototypes という名前を付けます。

次に、データベース内の各テーブルに対してプロトタイプモデルを作成します。

SELECT * from を使用して各テーブルから取得し、モデルを XML ファイルとして保存します:

モデル: Proto_Customers.xml

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

モデル: Proto_Suppliers.xml

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

モデル: Proto_Products.xml

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



プロトタイプビュー

プロトタイプビューを作成し、Demo_Prototype.html として保存して、試してみてください:

ビュー: 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>

試してみる »


では、すべてを1つにまとめましょう

最後に、少しの JavaScript コードを使用して、すべてのプロトタイプモデルに対してシンプルなプロトタイプページを作成します:

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>

結果を表示 »


その他の拡張