当前位置:K88软件开发文章中心编程语言Html5Html501 → 文章内容

AppML 案例模型

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-11 14:05:24

<AppML> 案例研究 - 应用程序模型此案例研究演示了如何构建一个完整的 <AppML> 互联网应用程序,具有针对数据库中的若干表进行信息列举、编辑和搜索的功能。应用程序模型在本章中,我们将为数据库中的 Customers 表建立一个完整的应用程序模型。<AppML> 过滤器如需允许过滤 <AppML> 数据,只需简单地向模型添加一个 <filters> 元素:实例:<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>如需全面了解,请参阅 <AppML> 参考手册。<AppML> 更新如需允许更新 <AppML> 数据,只需简单地向模型添加一个 <update> 元素:实例:<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>且向 <database> 元素添加一个 <maintable> 和 <keyfield> 元素:实例:<maintable>Customers</maintable><keyfield>CustomerID</keyfield>如需全面了解,请参阅 <AppML> 参考手册。<AppML> 安全您可以通过向 <AppML> 标签添加一个 security 属性来很容易地为 <AppML> 模型添加安全。实例:<appmlsecurity="admin">在上面的实例中,只有用户登录成为用户组 "admin" 的会员才能访问模型。如需为 <update> 元素设置安全,只需简单地向 <update> 元素添加一个 security 属性:实例:<updatesecurity="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>完整的 Customers 模型在本章中,我们将为数据库中的每个表设立一个应用程序模型。创建一个名为 Models 的新文件夹。在 Models 文件夹中,为每个应用程序创建一个模型。模型:Customers.xml<appml security=""><datasource><database> <connection>Demo</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>模型视图创建一个模型视图,把它保存为 Demo_Model.html,并尝试一下:视图:Demo_Model.htm<h1>Customers</h1><div id="List01"></div><script src="appml.js"></script><script>customers=newAppML("appml.htmlx","Models/Customers");customers.run("List01");</script>尝试一下 ?现在把所有的合并在一起然后,通过少量 JavaScript 编码,为所有模型创建一个测试页面: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><buttononclick='myOpen("Products")'>Products</button><buttononclick='myOpen("Suppliers")'>Suppliers</button><buttononclick='myOpen("Shippers")'>Shippers</button><buttononclick='myOpen("Categories")'>Categories</button><buttononclick='myOpen("Employees")'>Employees</button><buttononclick='myOpen("Orders")'>Orders</button><buttononclick='myOpen("OrderDetails")'>OrderDetails</button><br><br><div id="Place01"></div><script src="appml.js"></script><script>function myOpen(pname){var app_objapp_obj=newAppML("appml.php","Models/" + pname);app_obj.run("Place01");}</script></body></html>显示结果 ?

AppML 案例模型