网站首页 > 基础教程 正文
通过以下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 文件和文件夹:
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) |
猜你喜欢
- 2024-10-12 面试常客系列之跨域 java跨域面试题
- 2024-10-12 如何根治 Script Error. 如何根治神经性皮炎
- 2024-10-12 只用一个js文件,为你的网站加个黑暗模式
- 2024-10-12 闭包(一):闭包的9个应用场景 闭包一般用在什么地方
- 2024-10-12 LLM工程师应该如何防范提示注入?指导来了
- 2024-10-12 如何实现前端社交媒体分享功能 前端聊天功能如何实现
- 2024-10-12 「WWDC2018」-Web安全策略 web安全进阶
- 2024-10-12 「JS库」3个很棒的小众JavaScript库
- 2024-10-12 2 JavaScript核心 script标签 营养标签中的核心营养素
- 2024-10-12 GitHub精选 | Feather一组简单漂亮的开源图标
- 最近发表
- 标签列表
-
- gitpush (61)
- pythonif (68)
- location.href (57)
- tail-f (57)
- pythonifelse (59)
- deletesql (62)
- c++模板 (62)
- css3动画 (57)
- c#event (59)
- linuxgzip (68)
- 字符串连接 (73)
- nginx配置文件详解 (61)
- html标签 (69)
- c++初始化列表 (64)
- exec命令 (59)
- canvasfilltext (58)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- node教程 (59)
- console.table (62)
- c++time_t (58)
- phpcookie (58)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)