Web Page Development and Web Client API
Web页面开发和Web客户端提供的API
3.1 Overview 概述
To create or edit existing web pages, from the PowerFolder Console click 'Develop', then 'Web
Pages'. You can either edit an existing web page by clicking the 'Edit' button beside it or create a
new web page by entering its name in the box next to 'New Web Page' and clicking 'Create'.
Remember, new and editted web pages cannot be seen by outside viewers until they are deployed
under the 'Administer' section.
为了创建页面和编辑已有页面,从PowerFolder控制台单击Develop,然后Web
Pages.你可以编辑一个现存的页面,通过单击它旁边的Edit按钮,或者通过在New Web
Page' 旁的文本框中输入它的名字并且单击'Create'按钮来创建一个新页面。记住,新的
和编辑的页面不能从外部观察者看到直到他们在'Admimister'部分被发布为止。
Standard HTML is rather bland. It just displays things for the user to see, but it can't understand
commands issued by the user or 'do anything'. It can't read HTML 'form' parameters, it can't use
user submitted information to change the state of a workflow.
标准的HTML是相当谦逊的。它仅仅显示用户看到的,不过它不能理解用户发出的做
任何事情的命令。它不能阅读HTML form参数,它也不能利用用户提交的信息来改变工作
流的状态。
That is where 'client' comes in. By default, it is included with every web page in PowerFolder. Its
role is to simplify the process of making HTML 'intelligent'.
这就是client进入的原因。缺省情况下,它被包含在PowerFolder的每个页面之
中。它的作用是简化使HTML智能的过程。
Web pages in PowerFolder use Java JSP scripting and syntactically correct scripting means
following the JSP conventions. For a general script area within a web page, start it with '<%' and
end it with '%>'. For a one line script that writes output that the user will see, start it with '<%= '
and end it with '%>'.
PowerFolder中的web页面使用jsp脚本,通过JSP转换来得到正确的脚本含义。对
于一个页面中的脚本区域,它开始于<%,结束于%>,对于一行中的脚本,用于输出给用户可
见的内容,开始于<%=,结束于%>。
The goal of 'client' is to minimize the learning curve and make the scripting process more
enjoyable.
client的目标是使学习过程最小化而且使脚本流程更有趣。
PowerFolder can use any Java class or primitive, but by default it uses 3 variable types –
Boolean, Decimal, and String. In the view of 'client' these represent 'boolean', 'double', and
'java.lang.String' in Java.
PowerFolder可以使用任何java类和主类型,但缺省情况下它使用三种变量类型-
Boolean, Decimal, 和 String. 在client的观点来看,这些表示了Java中的boolean,
double, 和java.lang.String。
Note about below - when '()' is used to surround a name in a description, it is referring to an input
argument. For instance if 'startWorkflow("Hello")' will start a workflow with trigger data
'<powerfolder>Hello</powerfolder>', not '<powerfolder>(arguement1)</powerfolder>'.
注意下面内容,当()被用来在描述中包围一个名字时,它表示一个输入参数。例如如
果'startWorkflow("Hello")'将启动一个工作流,带有触发数据'<powerfolder>Hello
</powerfolder>',而不是'<powerfolder>(arguement1)</powerfolder>'。
3.2 Commands命令
3.2.1 Starting Workflows启动工作流
3.2.1.1 startWorkflow 启动工作流
Inputs – (none)输入-无
Return – (none)返回-无
Description - Starts a workflow with XML trigger '<powerfolder/>'.
描述-启动一个工作流,带有XML触发器 '<powerfolder/>'
Example – client.startWorkflow();
例子:client.startWorkflow();
3.2.1.2 startWorkflow 启动工作流
Inputs - arguement1 (String) 输入--参数1(字符串)
Return – (none) 返回--无
Description - Starts a workflow with XML trigger '<powerfolder>(arguement1)</powerfolder>'.
Note that (arguement1) is converted replaces special XML characters with their proper escape
codes (e.g. '<' becomes '<').
描述—
启动一个工作流,带有XML触发器'<powerfolder>(arguement1)</powerfolder>'。注意参数1
被转换成了特定的XML字符串,带有他们合适的编码信息。(例如<变成了<)
Example - client.startWorkflow("Change the temperature to 30 degrees Celius.");
例子--client.startWorkflow("Change the temperature to 30 degrees Celius.");
3.2.1.3 startWorkflowWithRequest带有请求启动工作流
Inputs - webValue (String)输入-web值(字符串)
Return – (none) 返回值(无)
Description - Starts a workflow with XML trigger
'<powerfolder>(client.getWebValue(webValue))</powerfolder>'. Note that
(client.getWebValue(webValue)) is converted replaces special XML characters with their proper
escape codes (e.g. '<' becomes '<').
描述:带有XML触发器来启动一个工作流
'<powerfolder>(client.getWebValue(webValue))</powerfolder>'。注意(client.getWebValue(we
bValue))被转换成为特定的XML字符串,带有合适的编码信息。(例如<变成了<)
Example - client.startWorkflowWithRequest("USER_NAME");
例子—client.startWorkflowWithRequest("USER_NAME");
3.2.1.4 startWorkflowWithXML带有XML启动工作流
Inputs - xmlValue (String)输入--xml值
Return – (none)返回--无
Description - Starts a workflow with '(xmlValue)'. No characters are converted.
描述--根据xml值来启动一个工作流,不进行转码
Example - client.startWorkflowWithXML("<employee><name>Cindy Smith</name><title>VP
of Sales</title></employee>");
例如--client.startWorkflowWithXML("<employee><name>Cindy Smith</name><title>VP of
Sales</title></employee>");
3.2.2 Selecting Existing Workflows选择已经存在的工作流
3.2.2.1 isNextWorkflowPresent 下一个工作流是否存在
Inputs – (none) 输入--无
Return – Boolean 返回--Boolean
Description - this does two things - determines if there is another workflow that has been been
selected from 'selectWaitingWorkflows' and 'selectWorkflows' and prepares this workflow's
attributes to be read and editted. Don't use this function after calling 'selectWorkflowById'.
Returns true if there is another selected workflow, false otherwise.
描述—这个做两件事情—
判断是否有另外一个工作流,它已经从selectWaitingWorkflows和selectWorkflows中被选中
,而且准备这个工作流的属性被读写。不要在调用selectWorkflowById后调用这个功能。
如果有另外一个被选中的工作流,返回true,否则返回 false
Example -例子
while (client.isNextWorkflowPresent()) {
client.setAttribute("Status", "Accepted");
}
3.2.2.2 selectWaitingWorkflows选择等候的工作流
Inputs - workflowName (String), state (String)输入--工作流名称,状态
Return – (none)返回-无
Description - select all workflows using script (workflowName)
描述-选择所有使用脚本workflowName的工作流
Example - client.selectWaitingWorkflows("EmployeeSetup", "NewComputerArrived");
例子--client.selectWaitingWorkflows("EmployeeSetup", "NewComputerArrived");
3.2.2.3 selectWorkflowById根据ID来选择工作流
Inputs - id (String)输入—id(字符串)
Return – (none)返回-无
Description - select the workflow having system ID equal to (id). Don't call
'isNextWorkflowPresent' after calling this function. The (id) specified will almost always be
derived from another function.
描述-
选择与id具有相同systemID的工作流。不要在调用这个功能以后调用isNextWorkflowPresen
t方法。指定的id应该从其他功能来得到。
Example - client.selectWorkflowById(client.getWebValue("ID"));
例子-client.selectWorkflowById(client.getWebValue("ID"));
3.2.2.4 selectWorkflows选择工作流
Inputs - query (String)输入-查询(字符串)
Return – (none)返回-无
Description - select all workflows that match the criteria specified in (query).
描述--选择所有的工作流符合在query中定义的关键词
Example - client.selectWorkflowById("*APP* = 'LocationFormSubmission' AND ?State? =
'NJ'");例子 - client.selectWorkflowById("*APP* = 'LocationFormSubmission' AND ?State? =
'NJ'");
3.2.3 Getting and Setting Workflow Attributes 得到和设置工作流属性
3.2.3.1 getAttribute得到属性
Inputs - attributeName (String)输入-属性名称(字符串)
Return - (String)返回(字符串)
Description - get the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述-得到应用指定的属性。不能用于内部属性。
Example – client.getAttribute("StreetAddress");
例子 - client.getAttribute("StreetAddress");
3.2.3.2 getBooleanAttribute得到布尔属性
Inputs - attributeName (String)输入--属性名称(字符串)
Return – (Boolean)返回-布尔值
Description - get the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述-得到应用指定的属性。不能用于内部属性。
Example - client.getBooleanAttribute("HasDriversLicense");
例子 – client.getBooleanAttribute("HasDriversLicense");
3.2.3.3 getDecimalAttribute得到数值属性
Inputs - attributeName (String)输入--属性名称(字符串)
Return - (Decimal)返回-数值
Description - get the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述-得到应用指定的属性。不能用于内部属性。
Example – client.getDecimalAttribute("BankBalance");
例子 - client.getDecimalAttribute("BankBalance");
3.2.3.4 getSystemAttribute得到系统属性
Inputs - attributeName (String)输入--属性名称(字符串)
Return - (String)返回(字符串)
Description - get the value of the system attribute. Can't be used on Internal Attributes. System
attributes are common to all workflows, but probably have different values.
描述-
得到应用指定的属性。不能用于内部属性。系统属性对于所有工作流是一样的,但可能会
有不同的值。
Example - client.getSystemAttribute("ID");
例子 – client.getSystemAttribute("ID");
3.2.3.5 releaseWaitAtState 释放等待状态
Inputs - stateName (String)输入--状态名称(字符串)
Return – (none)返回-无
Description - release the 'trace' waiting at the state. In addition, the 'STATUS' system attribute
for the workflow is changed to 'ACTIVE'.
描述—释放等候在状态上的路径。另外,工作流的系统属性STATUS被更改为ACTIVE.
Example - client.releaseWaitAtState("InventoryUpdated");
例子 – client.releaseWaitAtState("InventoryUpdated");
3.2.3.6 setBooleanAttribute设置布尔型的属性
Inputs - attributeName (String)输入--属性名称(字符串)
Return - (none)返回(无)
Description - set the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述--设置应用特定的属性值,不能用于内部属性。
Example - client.setBooleanAttribute("ShipmentDamaged", false);
例子 - client.setBooleanAttribute("ShipmentDamaged", false);
3.2.3.7 setDecimalAttribute设置数值型的属性
Inputs - attributeName (String)输入--属性名称(字符串)
Return - (none)返回(无)
Description - set the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述--设置应用特定的属性值,不能用于内部属性。
Example - client.setDecimalAttribute("Refund", 50);
例子 - client.setDecimalAttribute("Refund", 50);
3.2.3.8 setStringAttribute设置字符串型的属性
Inputs - attributeValue (String)输入--属性名称(字符串)
Return - (none)返回(无)
Description - set the value of the application-specific attribute. Can't be used on Internal
Attributes.
描述--设置应用特定的属性值,不能用于内部属性。
Example - client.setStringAttribute("BookOrdered", "Simon's Dictionary");
例子 - client.setStringAttribute("BookOrdered", "Simon's Dictionary");
3.2.4 Getting Web Values得到Web页面值
3.2.4.1 getNextWebValue得到下一个Web值
Inputs - webValue (String)输入webValue(字符串)
Return - (String)返回(字符串)
Description - get the next value from the collection of values generated from 'loadWebValues'.
描述--从loadWebValue生成的值集合中得到下一个值
Example - client.getNextWebValue();
例子 – client.getNextWebValue();
3.2.4.2 getWebValue得到web值
Inputs - webValue (String)输入webValue(字符串)
Return – (String)返回-(字符串)
Description - get web value submitted by an HTML 'input' tag. This is equivalent to the Java
servlet call 'request.getParameter("")'.
描述—得到通过一个HTML'input'标记而提交的web值。与java
servlet中调用request.getParameter("")等价。
Example - client.getWebValue("COMMENTS");
例子 - client.getWebValue("COMMENTS")
3.2.4.3 isNextWebValuePresent是否有下一个web值
Inputs - (none)
Return - (Boolean)
Description - determines if there is another value in the collection created by 'loadWebValues'.
Example - client.isNextWebValuePresent();
3.2.4.4 loadWebValues 读取web值集合
Inputs - webValue (String)
Return - (none)
Description - create a collection of web values with the same name (webValue).
Example - client.loadWebValues("ReviewedCases");
3.2.5 Arithmetic数学
3.2.5.1 add加
Inputs - arguement1 (Decimal), arguement2 (Decimal)
Return - (Decimal)
Description - adds two Decimals together. You really don't need to use this function, you can use
a simple '+' instead.
Example - client.add(client.getDecimalValue("TotalAttendees"), 1);
3.2.5.2 divide除
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Decimal)
Description - divides (arguement1) by (arguement2). You really don't need to use this function,
you can use a simple '/' instead.
Example - client.divide(client.getDecimalValue("DogYears"), 12);
3.2.5.3 multiply乘
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Decimal)
Description - multiplies (arguement1) with (arguement2). You really don't need to use this
function, you can use a simple '*' instead.
Example - client.multiply(client.getDecimalValue("GallonsOfGas"), 1.59);
3.2.5.4 subtract减
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Decimal)
Description - subtract (arguement2) from (arguement1). You really don't need to use this
function, you can use a simple '-' instead.
Example - client.subtract(client.getDecimalValue("BankBalance"), 20);
3.2.6 Logical逻辑
3.2.6.1 and逻辑与
Inputs - arguement1 (Boolean), argument2 (Boolean)
Return - (Boolean)
Description - true if both (arguement1) and (arguement2) are both true, false otherwise.
Example - client.and(client.getBooleanAttribute("collegeDegree"),
client.getBooleanAttribute("speaksLatin"));
3.2.6.2 isEqual相等
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) and (arguement2) are equal, false otherwise.
Example - client.isEqual(client.getDecimalAttribute("BlackjackHand"), 21);
3.2.6.3 isGreaterThan大于
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) is greater than (arguement2), false otherwise.
Example - client.isGreaterThan(client.getDecimalAttribute("Age"), 18);
3.2.6.4 isGreaterThanOrEqual大于或等于
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) is greater than or equal to (arguement2), false otherwise.
Example - client.isGreaterThanOrEqual(client.getDecimalAttribute("FrequentFlyerMiles"),
25000);
3.2.6.5 isLessThan小于
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) is less than (arguement2), false otherwise.
Example - client.isLessThan(client.getDecimalAttribute("ShoeSize"), 10);
3.2.6.6 isLessThanOrEqual小于或等于
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) is less than or equal to (arguement2), false otherwise.
Example - client.isLessOrEqualThan(client.getDecimalAttribute("StrikeOuts"), 45);
3.2.6.7 isNotEqual不等于
Inputs - arguement1 (Decimal), argument2 (Decimal)
Return - (Boolean)
Description - true if (arguement1) is not equal to (arguement2), false otherwise.
Example - client.isLessOrEqualThan(client.getDecimalAttribute("PrimeNumber"), 2);
3.2.6.8 not逻辑非
Inputs - arguement1 (Boolean)
Return - (Boolean)
Description - true if (arguement1) is false, false otherwise.
Example - client.not(client.getBooleanValue("PassedExam"));
3.2.6.9 or逻辑或
Inputs - arguement1 (Boolean), argument2 (Boolean)
Return - (Boolean)
Description - true if either or both (arguement1) and (argument2) are true, false otherwise.
Example - client.or(client.getBooleanValue("HasCollegeDegree"),
client.getBooleanValue("Has5YearsExperience"));
3.2.6.10 xor逻辑异或
Inputs - arguement1 (Boolean), argument2 (Boolean)
Return - (Boolean)
Description - true if either, but not both, (arguement1) or (argument2) is true, false otherwise.
Example - client.or(client.getBooleanValue("RedLight"),
client.getBooleanValue("CrossingIntersection"));
3.2.7 Other其它
3.2.7.1 convertStringToDecimal转换字符串到数值
Inputs - arguement1 (String)
Return - (Decimal)
Description - converts (arguement1) to a Decimal.
Example - client.convertStringToDecimal(client.getWebValue("AGE"));
3.2.7.2 isStringDecimal是否是数值
Inputs - arguement1 (String)
Return - (Boolean)
Description - true if (arguement1) can be converted to a Decimal, false otherwise.
Example - client.isStringDecimal(client.getWebValue("Quantity"));
3.2.7.3 saveChanges保存修改
Inputs - (none)
Return - (none)
Description - saves the changes made to all selected workflows.
描述--保存对于所有选中工作流所做的修改
Example - client.saveChanges();