当前位置: 首页 > 网络学院 > 客户端脚本教程 > APPML > 案例研究:产品

APPML
AppML 简介
AppML 案例
AppML 案例说明
AppML 网络服务
案例研究简介
案例研究:数据库
案例研究:AppML
案例研究:HTML 报告
案例研究:HTML 表单
案例研究:目录
案例研究:产品
案例研究:托运人
案例研究:供应商
案例研究:客户
案例研究:雇员
案例研究:应用程序
案例研究:下载
AppML FAQ
AppML 文档
AppML 数据库元素

APPML 中的 案例研究:产品


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 721 ::
收藏到网摘: n/a

This chapter demonstrates AppML on the Products table in the Northwind database.
这章介绍了AppML在Northwind 数据库中产品表格的应用。


The Products XML File
产品XML文件

The "Products" AppML description: northwind/products.xml
“产品” AppML 描述:northwind/products.xml


AppML HTML Report
AppML HTML 报告

HTML Report: appml.asp?appname=northwind/products&displaytype=report
HTML 报告:appml.asp?appname=northwind/products&displaytype=report

The link above runs the AppML HTML report service. To be able to run an AppML HTML report, the AppML description must contain an <htmlreport> tag.
上述链接运行了AppML HTML 报告服务。为了能够运行AppML HTML 报告,AppML描述必须包含一个<htmlreport>标签。

We see that the report contains a header ("Products"), a table listing the different products along with category, supplier, and quantity per unit. The report also lists the number of records at the bottom. The title and sql selection shown in the report, is taken from the <title> tag (under the <appml> tag) and the <sql> tag inside <htmlreport>. The number of records are automatically added by AppML.
我们都看到,这份报告包含了一个页眉(“产品”),一个根据目录、供应商和单位数量列举不同产品的表格。报告还在底部列举了记录的数量。报告中展示的标题 和SQL选集是从<htmlreport>内部的<title>标签(在<appml>之下)和< sql>标签提取出来的。记录数量通过AppML自动被添加的。

This report also have a Filter button. If you click on the Filter button, you can filter and sort the report. You can also determine in what format you want to show the report (Normal, Word, Excel, or XML).
这份报告还包含了一个过滤按钮。如果你点击了过滤按钮,你就可以报告进行过滤和分类。你同样可以定义报告显示的格式(正常、Word、Excel 或 XML)。

The <filters> tag in "products.xml" looks like this:
“products.xml” 中的<filters>标签显示如下:

<filters>
<orderby>products.productname</orderby>
<query>
<field>productname</field>
<label>Product name</label>
</query>
<query>
<field>suppliers.companyname</field>
<label>Supplier</label>
<sql>SELECT DISTINCT companyname
FROM suppliers ORDER BY companyname</sql>
</query>
<query>
<field>categories.categoryname</field>
<label>Category</label>
<sql>SELECT DISTINCT categoryname
FROM categories ORDER BY categoryname</sql>
</query>
<orderselect>
<field name="products.productname">Product Name</field>
<field name="suppliers.companyname">Supplier</field>
<field name="categories.categoryname">Category</field>
</orderselect>
</filters>

We see that the <filters> tag contains an <orderby> tag, several <query> tags, and an <orderselect> tag.
我们看到,<filters>标签包含了一个<orderby>标签、部分<query>标签和一个<orderselect>标签。

The <orderby> tag specifies which field the report should be ordered by. In this case, the report will be ordered by the productname field in the Products table.
<orderby>标签指定了报告该以什么自动为基准进行排序。在这个案例中,该报告将通过产品表格中的产品名称字段进行排序。

The <query> tags defines which fields the user can search on. The <field> tag defines the name of the field in the table, and the <label> tag defines the label that will be visible for the user. In this case, the user can search on "Product name", "Supplier", and "Category".
<query>标签定义了用户可以根据什么字段进行搜索。<field>标签定义了表格中的字段名称,<label>标签定义了标签对于用户来说是否可视。

Inside the "Supplier" and "Category" <query> tag, there is an <sql> tag. The <sql> tag indicates that AppML should create a drop-down box where the user can select an existing supplier and/or category to search on.
在“供应商” 和 “目录” <query>标签内部包含了一个<sql>标签。<sql>标签指示AppML应该针对用户对现存的供应商或目录进行搜索的需要来创建一个下拉列表框。

The <orderselect> tag specifies other order-by options for the user. Here, the user can determine if the report should be ordered by "Product name", "Supplier", or "Category".
<orderselect>标签为用户指定了其它类型的排序选项。这里,用户可以定义它应该按照“产品名称”、“供应商” 或是“目录”来进行排序。

The <filters> tag is used by both <htmlreport> and <htmllist>.
<filters>标签通过<htmlreport>和<htmllist>进行使用。


AppML HTML Form
AppML HTML 表单

HTML Form: appml.asp?appname=northwind/products&displaytype=form
HTML 表单:appml.asp?appname=northwind/products&displaytype=form

The link above runs the AppML form service. To be able to run AppML form, the AppML description must contain an <htmlform> tag. The AppML description must also contain a <maintable> tag and a <keyfield> tag (inside the <database> tag).
上述链接运行了AppML表单服务。为了能够运行AppML HTML 报告,AppML描述必须包含一个<htmlreport>标签。AppML描述必须还要包含一个<maintable>标签和一个<keyword>标签(位于<database>标签内部)。

The link above takes you to a page with a blank form. Here you can add a new record. AppML automatically adds New, Submit, and Delete buttons.
上述链接可以使你重新打开一个全新的空白页面。你可以在里面添加全新的记录。AppML会自动添加新记录按钮、提交按钮和删除按钮。

This time we have specified the look of the form with standard HTML code. The <htmlform> tag in "products.xml" looks like this:
我们已经依据HTML代码的标准指定了表单的外观。“products.xml”中的<htmlform>标签如下:

<htmlform>
<sql>
SELECT productname,supplierid,categoryid,QuantityperUnit,unitprice,
unitsinstock,unitsonorder,reorderlevel,discontinued
FROM products
</sql>
<form>
<br/>
<table width="40%">
<tr>
<td>
<fieldset>
<legend style="color:darkblue">Product information</legend>
<br/>
<table>
<tr>
<td>Product Name:</td>
<td><input size="40" maxlength="40" id="productname"/></td>
</tr>
<tr>
<td>Supplier:</td>
<td>
<field name="supplierid">
<function name="dbselect">
<sql>SELECT supplierid,companyname FROM suppliers
ORDER BY companyname</sql>
<value>supplierid</value>
<options>companyname</options>
</function>
</field>
</td>
</tr>
<tr>
<td>Category:</td>
<td>
<field name="categoryid">
<function name="dbselect">
<sql>SELECT categoryid,categoryname FROM categories
ORDER BY categoryname</sql>
<value>categoryid</value>
<options>categoryname</options>
</function>
</field>
</td>
</tr>
<tr>
<td>Quantity per Unit:</td>
<td><input size="20" maxlength="20" id="quantityperunit"/></td>
</tr>
<tr>
<td>Price per Unit:</td>
<td><input size="6" maxlength="8" id="unitprice"/></td>
</tr>
<tr>
<td>Units in Stock:</td>
<td><input size="6" maxlength="2" id="unitsinstock"/></td>
</tr>
<tr>
<td>Units on Order:</td>
<td><input size="6" maxlength="2" id="unitsonorder"/></td>
</tr>
<tr>
<td>Reorder Level:</td>
<td><input size="6" maxlength="2" id="reorderlevel"/></td>
</tr>
<tr>
<td>Discontinued:</td>
<td><input type="checkbox" id="discontinued"/></td>
</tr>
</table>
<br/>
</fieldset>
</td>
</tr>
</table>
</form>
</htmlform>

The sql selection for the form is specified in the <sql> tag inside <htmlform>.
关于表单的sql选集被指定在了<htmlform>中<sql>标签的内部。

The look of the input form is specified inside the <form> and </form> tags. Here we use standard HTML (like <table> tags, <fieldset> and <legend>, and <input>).
输入表单的外观被指定在了<form>标签和</form>标签的内部。在这里,我们使用的是标准的HTML代码(如:< table>标签、<fieldset>标签、<legend>标签和<input>标签)。

Notice that to show the data from a database and to make the data updateable, we set the id attribute of the input tags equal to the fieldnames in our sql selection.
注意:对于显示数据库数据和更新数据来说,设置<input>标签中的id属性和设置sql 选项集中的字段名属性的效果是一样的。

Another AppML function is also demonstrated in the <htmlform> above. Twice in the code we have used an AppML function called dbselect. Look at the code fragment below:
另外一个AppML函数同样在上述的<htmlform>中作出了解释。在代码中我们两次用到了名为“dbselect” 的AppML函数。请看下面的代码片断:

<td>Supplier:</td>
<td>
<field name="supplierid">
<function name="dbselect">
<sql>SELECT supplierid,companyname FROM suppliers
ORDER BY companyname</sql>
<value>supplierid</value>
<options>companyname</options>
</function>
</field>
</td>

To use the dbselect function, you must first specify the fields you want to use the function on (in this case "supplierid"). The supplierid field contains a supplier ID that refers to a company name in the "Suppliers" table. The <sql> tag selects the supplierid and the companyname fields from the "Suppliers" table. The <value> tag indicates the value that will be saved in the form (supplierid) and the <options> tag indicates the value displayed (companyname) to the user in the drop-down box. This way, AppML gives us the opportunity to create selectable lists inside our forms.

为了使用dbselect 函数,你首先必须制定函数作用的字段(见“supplierid” 中的案例)。”supplierid“字段中包含了供应商的ID ,同时涉及到“供应商”表格中他所在的公司名称。<value>标签指示的值将被保存在“supplierid” 表单中,<option>标签指示的(显示公司名称的)值将出现在下拉框中。通过这个方法,AppML将为我们提供一个在表单中创建可选列表 的机会。


AppML HTML List
AppML HTML 列表

HTML List: appml.asp?appname=northwind/products&displaytype=list
HTML 列表:appml.asp?appname=northwind/products&displaytype=list

The link above runs the AppML list service. To be able to run AppML list, the AppML description must contain an <htmllist> tag.
上述链接运行了AppML列表服务。为了能够创建AppML列表,AppML描述必须包含一个<htmllist>标签。

We see that the list contains a header ("Products"), the number of records in the list, a Filter button, a New button, a Report button, and a table listing the different products.
我们都看到,这份报告包含了一个页眉(“目录”)、列表中的记录数、一个过滤按钮、一个新按钮、一个报告按钮和一个罗列不同产品的表格按钮。

The title and sql selection shown in the report, is taken from the <title> tag and the <sql> tag inside <htmllist>. The number of records and the buttons are automatically added by AppML.
报告中展示的标题和SQL选集是从<htmllist>内部的<title>标签和<sql>标签提取出来的。记录的数量和按钮是自动添加到AppML中的。

The Filter button is automatically added because the AppML description contains a <filters> tag.
过滤按钮是自动添加的,因为AppML描述包含了一个<filters>标签。

The New button is automatically added because the AppML description contains an <htmlform> tag.
新 按钮是自动添加的,因为AppML描述包含了一个<htmlreport>标签。

The Report button is automatically added because the AppML description contains an <htmlreport> tag.
报告按钮是自动添加的,因为AppML描述包含了一个<htmlreport>标签。

The Folder image to the left of each records is automatically added because the AppML description contains an <htmlform> tag. If you click on the Folder image, you will be taken to the AppML form.
每条记录左边的文件夹图像是自动添加的,因为AppML描述包含了一个<htmlform>标签。如果你点击了文件夹图像,你将会进入AppML表单。

This list is not an editable list (like Categories in the previous chapter). Here you must edit the data in the form.
这个列表并不是一个可编辑列表(如同前一章的目录列表一样)。在这里,我们可以编辑表单中的数据。


AppML XML Report
AppML XML 报告

XML Report:
appml.asp?appname=northwind/products&displaytype=report&type=xml

XML 报告:
appml.asp?appname=northwind/products&displaytype=report&type=xml

The link above runs the AppML XML service.
上述链接运行了AppML XML 服务。

The AppML XML report service above will generate an XML report based on the sql defined in the <htmlreport> element. The XML report's root element is <table>. The first element after <table> is <sql>, which lists the sql used in the description. Then there will be one <row> element for each record in the sql. The <row> element contains one element for each field in the sql.

上述的AppML XML报告服务将会产生一个基于在<htmlreport>元素中定义的sql来产生一个XML报告。XML报告的根元素是< table>。在<table>之后的第一个元素是<sql>,它罗列了在描述中使用的sql。对于sql中每一条记录而 言,都会包含一个<row>元素。<row>元素为sql中的每条字段包含了一个元素。


All AppML Services in One
所有的AppML 服务

To run all the AppML services above in one, use the following link:
appml.asp?appname=northwind/products

希望运行上面的AppML服务,可以点击下面的链接:
appml.asp?appname=northwind/products


评论 (0) All

登陆 | 还没注册?