如何使用 <AppML>
通過以下4個簡單的步驟演示如何創建<AppML>的應用程序。
1.創建模型(Model)
使用以下內容創建文件
<appml>
<datasource>
<database>
<connection>Demo</connection>
<sql>SELECT CustomerName,ContactName,City,Country FROM Customers</sql>
<orderby>CustomerName</orderby>
</database>
</datasource>
<filters>
<query>
<field>CustomerName</field>
</query>
</filters>
</appml>
在子目錄中Models(我們建議)將該文件保存為 Customers.xml。
模型解析
<appml> 標籤定義了模型。
<datasource>標籤定義模型的數據源。
<database>標籤定義資料庫。
<connection>標籤定義資料庫的鏈接。
<sql>標籤定義數據查詢
<orderby>標籤定義默認排序。
<query>標籤定義合法的查詢過濾器。
2. 創建 WEB 頁面
在第一個 <AppML> app中,創建一個 HTML頁面:
實例
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Application</h1>
<table>
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Berlin</td>
<td>Germany</td>
</tr>
</table>
</body>
</html>
3. 添加樣式
在你的web頁面中添加層疊樣式在執行e <AppML> app:
實例
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="appml.css">
</head>
<body>
<h1>My First Web Application</h1>
<table class="appmltable">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Berlin</td>
<td>Germany</td>
</tr>
</table>
</body>
</html>
4. 添加腳本, 然後執行應用
在你的web頁面中添加腳本來運行 <AppML> app:
實例
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="appml.css">
</head>
<body>
<h1>My First Web Application</h1>
<div id="Place01">
<table id="Template01" class="appmltable">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr id="appml_row">
<td>#CustomerName#</td>
<td>#City#</td>
<td>#Country#</td>
</tr>
</table>
</div>
<script src="appml.js"></script>
<script>
app=new AppML("appml.htmlx","Models/Customers.xml");
app.run("Place01","Template01");
</script>
</body>
</html>
實例解析
<AppML> 庫中含有大量的函數。這些函數可以再你的web頁面中調用。
<script src="appml.js"> 載入了 <AppML> 庫。
JavaScript 語句: app=new AppML("appml.htmlx","Models/Customers.xml"); 創建 AppML 應用對象, 然後執行web服務端腳本 "appml.htmlx" 來載入 "Customers.xml"文件的數據。
JavaScript 語句 app.run("Place01","Template01"); 將數據插入到 id="Place01" 的HTML元素中, 使用 id="Template01" 屬性元素作為模板。
屬性 id="appml_row" 定義了每條數據插入到HTML元素中。
# 標記中的數據會使用模型的數據替換。
以上所有,你可以想像到更快的原型嗎?
它是如何工作的?
當web頁面載入時, 你可以再頁面中載入 <AppML> 控制器。
使用 <AppML> 控制器, 你可以再頁面創建 <AppML> 對象。
當你在頁面中運行 <AppML> 對象, 它會請求服務端數據控制器。
<AppML> 對象從伺服器接收數據 (使用數據模型)。
<AppML> 對象 (或者你的代碼) 在頁面中顯示數據。
(可選) web用戶可以改變數據。
(可選) <AppML> 可以在伺服器後台發送數據。
(可選) 伺服器控制器可以在服務端存儲數據。
典型的 Web 文件和文件夾:
沒有限制
可以將 <AppML> 對象放在 HTML 頁面。 <AppML> 不影響頁面的其他部分。
<AppML> 在方案頁面不存在時默認為標準的顯示頁面。 這是完美的快速原型。
但是 <AppML> 主要功能不是用於頁面的顯示。 <AppML> 主要是讀取 應用程序數據. 它帶來的數據可以通過自由的使用 HTML, CSS, 和 JavaScript 來設計它們的顯示效果。你可以:
自己編寫HTML,讓AppML處理數據。
調用模型,並處理所有的顯示。
使用AppML的屬性和方法,創建其它的組合。
你很快會發現 <AppML>具備了強大的功能,它可以為你的web應用提供數據和數據模型。你可以:
為用戶或用戶組定義數據安全
連接所有類型資料庫, 如 Access, MySQL, SQL, 和 Oracle
連接 XML 文件和 Text 文件
定義數據類型,數據格式,數據限制。
給模型添加任何新元素。
web文件夾: Demo
數據文件夾: Data
圖片文件夾: Images
模型文件夾:Models
應用: Demo.htm
樣式: Demo.css
<AppML> 配置文件: appml_config.php(或者 .htmlx)
<AppML> 樣式文件: appml.css
<AppML> 瀏覽器控制器: appml.js
<AppML> 伺服器控制器: appml.php (or .htmlx)
※ASP.NET Web Forms-資料庫連接
※ASP.NET Web Forms-導航
※ASP.NET Web Forms-實例
※ASP.NET Web Forms-HTML 伺服器控制項
TAG:程序員小新人學習 |