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

APPML
AppML HTML 报告
AppML 过滤函数
AppML HTML 列表
AppML HTML 表单
AppML XML 报告

APPML 中的 案例研究:客户


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

This chapter demonstrates AppML on the Customers table in the Northwind database.
这章讲述了AppML基于Northwind数据库中客户表格的应用。


The Customers XML File
客户XML文件

The "Customers" AppML description: northwind/customers.xml
“客户”AppML描述:northwind/shippers.xml


AppML HTML Report
AppML HTML 报告

HTML Report: appml.asp?appname=northwind/customers&displaytype=report
HTML 报告:appml.asp?appname=northwind/customers&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 ("Customers"), a table listing the different companies along with their contact person, address, city, and country. 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 "customers.xml" looks like this:
“customers.xml” 中的<filters>标签显示如下:

<filters>
<orderby>Companyname</orderby>
<query>
<field>Companyname</field>
</query>
<query>
<field>City</field>
<sql>SELECT DISTINCT city FROM customers ORDER BY city</sql>
</query>
<query>
<field>Country</field>
<sql>SELECT DISTINCT country
FROM customers ORDER BY country</sql>
</query>
<orderselect>
<field>Companyname</field>
<field>Contactname</field>
<field>City</field>
<field>Country</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 Companyname field in the Customers 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 "Companyname", "City", and "Country".
<query>标签定义了用户可以根据什么字段进行搜索。<field>标签定义了表格中的字段名称,< label>标签定义了标签对于用户来说是否可视。在这个案例中,用户可以根据 “公司名称” 、“城市” 以及 “国家” 进行搜索。

Inside the "City" and "Country" <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 city and/or country 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 "Companyname", "Contactname", "City", or "Country".
<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/customers&displaytype=form
HTML 表单:appml.asp?appname=northwind/customers&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描述必须包含一个<htmlform>标签。AppML描述必须还要包含一个<maintable>标签和 一个<keyfield>标签(位于<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 "customers.xml" looks like this:
我们已经依据HTML代码的标准指定了表单的外观。“customers.xml”中的<htmlform>标签如下:

<htmlform>
<sql>
SELECT customerid,companyname,contactname,contacttitle,
address,city,region,postalcode,country,phone,fax
FROM Customers
</sql>
<elements>
<field name="customerid">
<required/>
</field>
</elements>
<form>
<br/>
<table width="50%">
<tr>
<td>
<fieldset>
<legend style="color:darkblue">Customer Information</legend>
<br/>
<table>
<tr>
<td>CustomerID:</td>
<td colspan="3"><input size="5" maxlength="5" id="customerid"/>
</td>
</tr>
<tr>
<td>Customer Name:</td>
<td colspan="3"><input size="40" maxlength="40" id="companyname"/>
</td>
</tr>
<tr>
<td>Contact Name:</td>
<td colspan="3"><input size="30" maxlength="30" id="contactname"/>
</td>
</tr>
<tr>
<td>Title:</td>
<td colspan="3"><input size="30" maxlength="30" id="contacttitle"/>
</td>
</tr>
<tr>
<td>Address:</td>
<td colspan="3"><input size="60" maxlength="60" id="address"/></td>
</tr>
<tr>
<td>City:</td>
<td><input size="15" maxlength="15" id="city"/></td>
<td>Region:</td>
<td><input size="15" maxlength="15" id="region"/></td>
</tr>
<tr>
<td>PostalCode:</td>
<td><input size="15" maxlength="10" id="postalcode"/></td>
<td>Country:</td>
<td><input size="15" maxlength="15" id="country"/></td>
</tr>
<tr>
<td>Phone:</td>
<td><input size="24" maxlength="24" id="phone"/></td>
<td>Fax:</td>
<td><input size="24" maxlength="24" id="fax"/></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 <elements> tag is a container for the data fields in an HTML form or in an editable HTML list that should fulfill special criterions. In the code above, we specify that the field customerid is required (cannot be left blank in the form). If a user leave this field blank, AppML will generate an error message telling that the field has to be filled with data.
<element>标签是HTML表单或可编辑的HTML列表(这些列表必须遵循一定的规范)中的数据字段容器。在上述代码中,我们指出“公 司名称” 字段和“联系名称” 字段是必要的(不可以在表单中以空白显示)。如果一个用户对这两个字段留以空白,AppML将产生错误信息,并提示你填满表格。

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 选项集中的字段名属性的效果是一样的。


AppML HTML List
AppML HTML 列表

HTML List: appml.asp?appname=northwind/customers&displaytype=list
HTML 列表: appml.asp?appname=northwind/customers&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 ("Customers"), the number of records in the list, a Filter button, a New button, a Report button, and a table listing the different customers.
我们都看到,这份报告包含了一个页眉(“客户”)、列表中的记录数、一个过滤按钮、一个新按钮、一个报告按钮和一个罗列不同产品的表格按钮以及罗列了不同客户的表格。

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表单。

The <htmllist> tag in "customers.xml" looks like this:
“customers.xml” 文件的<htmllist>标签如下:

<htmllist>
<sql>
SELECT Companyname, ContactName AS [Contact Name],City,Country,
customerid as Orders
FROM Customers
</sql>
<server>
<field name="Orders">
<display>
<a href="appml.asp?appname=northwind/orders&amp;filter=
customers.companyname&amp;value=#appml:field(name='companyname')">
Orders</a>
</display>
</field>
</server>
</htmllist>

In the list, notice the column called "Orders". This column is a link that goes to the "Orders" application and shows the orders for each customer.
在列表中我们可以发现名为“Orders”的列。这个列链接到“Orders” 应用程序中,并且,它将显示每个客户的顺序。


AppML XML Report
AppML XML 报告

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

XML 报告:
appml.asp?appname=northwind/customers&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/customers

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


评论 (0) All

登陆 | 还没注册?