Openbiz 2.x 手册中文版, 中文Powerpoint 教程, Openbiz 中文论坛
Openbiz提供了一个PHP 应用程序框架。它可以帮助专业软件开发人员和技术咨询家来构建网络上企业级应用。由于企业级应用的高复杂性,系统开发通常会包括巨大投资和冗长的时间去进行工程计划,系统设计,原型设计,组件编码,功能测试,产品部署以及维护。
Openbiz框架的目标是节省复杂应用的开发投入和缩短开发时间。借助于Openbiz的帮助,应用程序的开发将建立于一个拥有完全互联网(Web)层面的,以Metadata驱动为核心的,并且有Eclipse插件作为图形化编写工具的平台。
Openbiz是一个Metadata驱动的框架。这意味着Openbiz对象(Objects)的创立是基于Metadata的文字描述。构建一个应用意味着设计和编写XML格式的Metadata文件。因此,基于Openbiz的应用软件包是完全可客户化的,而且是极其容易开发和维护的。
Openbiz被设计成一个多层面的结构。以下的图表说明了这一点。它涵盖了完全互联网(Web)层面,从网页流览器作为客户机到服务器这边的数据整合层面。使用Openbiz,软件开发者可以节省花在与其他软件库接口的工作。

Openbiz框架内部继承了MVC(模型-视图-控制器)的设计模式。这使得基于Openbiz的应用非常容易来开发和管理,因为表述层的程序与商业数据和逻辑清楚地分离开来。
Openbiz的内核实现了对象关系映射功能。Openbiz以BizDataObj对象来表述数据库表格和它们之间的逻辑关系。Openbiz支持的映射包括一对多,多对一,一对一和多对多的对象逻辑关系,并且支持与标准结构化查询语言(SQL)相似的查询语言。
安全性是现今商业应用环境中必不可少的组成部分。Openbiz的安全模型可用来创建用户身份验证,基于角色的视图许可控制以及基于属性的数据许可控制。
Openbiz的编辑工具与当前最流行的Eclipse开发环境集成在一起。Openbiz的编辑工具是一个Eclipse的插件。它提供几种不同的向导来帮助开发人员创建新的Metadata文件,并提供图形用户界面来编辑这些文件。与此同时开发人员可以利用Eclipse的其他强大功能。
这个文件介绍Openbiz 2.2 在版本2.1之上的新改进的特点 。Openbiz 2.1 指南仍然可在版本2.2使用 。
NOTE: 从Openbiz 2.2.1.1, 强力推荐使用Web Installer. 将Openbiz 下载后解压缩到某一个目录. 在浏览其中键入 http://localhost/openbiz_install_dir/demoapp/index.php. 然后沿着提示走下去.
Openbiz 2.2.1.1之前的版本用下面的步骤.
1. 下载 Openbiz 2.2 source, 下载 Zend Framework source。为得到更高的性能, 推荐使用APC extension。 A topic on apachelounge介绍了在windows安装APC 。
2. 在openbiz_home/bin/sysheader.inc 配置Zend framework 路径。例如, 如果Zend framework library 是在/htdocs/zf015/, 需在sysheader.inc 增加以下的定义。
| // defined Zend framework library home as ZEND_FRWK_HOME define('ZEND_FRWK_HOME',$_SERVER['DOCUMENT_ROOT']."/zf015/library"); // add zend framework to include path set_include_path(get_include_path() . PATH_SEPARATOR . ZEND_FRWK_HOME); |
1. 改变Config.xml Database Driver属性。 http://us2.php.net/manual/en/ref.pdo.php#pdo.drivers 给除了支持的PDO Driver名单。
2. 启动Openbiz dempapp, 在浏览器中键入 http://localhost/ob22/demoapp/demo.html。演示中事件管理应用的home 被改变到 http://localhost/ob22/demoapp/bin/home.php, 而不是在2.1 版本的 http://localhost/ob22/demoapp/pages/EventMgr.htm
产生报表是商业应用一个非常重要特点。通过利用 BIRT 报表服务器, Openbiz 应用从BizForm/BizDataObj 中产生报表。
BIRT 是一个基于Eclipse的报表系统, 它集成以您的Java/J2.EE 应用产生高质量报表。在开源之报表工具中, BIRT 是最佳的一个。它的Eclipse报表设计师让您从数据库桌和其它数据源(即xml 和csv 文件) 创造漂亮的报表。
BIRT 服务器的最简单的设施是使用BIRT 观察者。好参考可能被发现在The simplest installation of BIRT server is using BIRT viewer. A good reference can be found at Installing the BIRT Viewer in Tomcat.
Openbiz 使用它的reportService 与BIRT viewer 服务器集成。创造BIRT 报告模板和用BIRT viewer 显示报告的步骤:
| resultset in .rptdesign | resultset in template |
<list-property name="resultSet"> |
<list-property name="resultSet"> |
Tabs 非常普遍地被使用在企业应用和消费者网站。在许多商业应用, subtabs 是常见的widgets 用来组织界面元件之间父子关系。
Openbiz 2.2 以BizView HTMLTab 类的一个新属性和ViewSet 属性的组合来支持tabs and subtabs 。
HTMLTab 类样品metadata xml 文件是在demoapp/metadata/demo/Tabs.xml 和demoapp/metadata/demo/EventTabs.xml 。
| demo/Tabs.xml |
<?xml version="1.0" standalone="no"?> |
| demo/EventTabs.xml |
<?xml version="1.0" standalone="no"?> |
有一样的ViewSet = "EventSet " 的对应的视图(view)
| demo/EventView.xml | demo/EventRegistView.xml |
<?xml version="1.0" standalone="no"?> |
<?xml version="1.0" standalone="no"?> |
由于EventView 和EvenrRegistView 分享同样ViewSet, 在他们之间互换将保留对FMEvent 和它的BOEvent 同样对象的上下文。例如, 在EventView 用户在上面的form 查询"*Tennis*" , 当他点击Registration sub tab, 换到EventRegistView, 同样的查询结果被保留在新视图。
以优秀品质设计企业网应用通常需要web 设计师。Openbiz 2.2 demoapp 带来新的界面样式:
当然开发商可以改变在demoapp/css 之下德css 文件来应用他们自己的样式。
Openbiz 2.2 中的一个新类是BizFormTree (Openbiz 1.1 有相似的类). 这个类是为了解决一个共同的问题, 树状结构保存在一个数据库表中. 这个表包含ID 和ParentID columns. BizFormTree 允许用户浏览树,并添加/删除/编辑树节点.
BizFormTree 是一个特殊BizForm.它利用BizForm.dtd文件作为其xml schema. BizFormTree 目的是表现在一个数据库表中的树的层次关系.
举例来说, event table schema: (every record has PARENT_ID column which builds tree hierarchy relationship between the records in the same table)
| Column | Comments |
| SYSID | Primary key |
| NAME | Event name |
| PARENT_ID | Store the SYSID of its parent event. |
BizFormTree 需要映射BizDataObj 中的两个BizFields "Id" 和 "PId". "PId" 对应于table column parent id. 这个类提供两个新的方法
该类将 parent object array 输出的 smarty template. 以parent array, 开发者可显示当前纪录的父结构. BizFormTree metadata 的例子是
| <BizCtrlList> <BizCtrl Name="bctrl_Id" FieldName="Id" DisplayName="Id"/> <BizCtrl Name="bctrl_name" FieldName="Name" DisplayName="Name" Link="javascript:CallFunction('{@:Name}.ListChildren({@:Control[bctrl_Id].Value})')"/> <BizCtrl Name="bctrl_pid" FieldName="PId" DisplayName="PId"/> </BizCtrlList> |
The template is like
| {section name=i loop=$parents} {if $smarty.section.i.index != 0} > {/if}<a href="javascript:CallFunction('demo.FMEventTree.ListSiblings({$parents[i].Id}))')">{$parents[i].Name}</a> {sectionelse} {/section} |
下图显示了应用BizFormTree 和 list_tree.tpl 的一个例子.

蓝色文字表示Openbiz 2.2 中新的元素
<!--OpenBiz BizObj metadata DTD--> <!ELEMENT TableJoins (Join+) > |
<!--OpenBiz BizView metadata DTD--> |
<!--OpenBiz BizForm metadata DTD--> <!ELEMENT DisplayModes (Mode+) > |
<!--OpenBiz Plugin service metadata DTD--> |
这份文件是openbiz2.0手册. Openbiz1.x的手册在manual11.html
其他链接:openbizeclipse插件设计师手册, openbiz最佳做法
Openbiz 2.0是一个metadata驱动的框架. 所有openbiz对象都有自己的metadata文档. Openbiz2.0建筑架构遵循模型-视图-控制器(MVC)的设计模式,它也实现了对象/关系映射.
Openbiz的目标是使设计,开发和维护应用软件容易. Openbiz是xml数据驱动框架,即openbiz对象建基于描述他们的数据档案. 建立一个应用意味着设计和开发数metadata文档. 由于自我阐释性标示语言, 应用易于维护. 与此同时由于XML的可扩展性, openbiz是一个可扩展的框架.
下面的图表显示了基于metadata 对象的openbiz框架. 这些对象涵盖大部分功能需求的Web应用开发.

Openbiz其中一个关键的优势是,它是一个遵循模型-视图-控制器(MVC)的设计模式的框架. This makes Openbiz applications much more manageable because the presentation code (View) is cleanly separated from the application data and logic (Model).这使得Openbiz应用更为可控,因为表现编码(视图)与应用和数据逻辑(模型)分离得十分干净. 所有使用者介面与应用处理都由一个前端控制器控制.

比较Openbiz MVC设计与市场上现有的MVC框架, 如JSF和Struts, Openbiz是比较接近JSF, 因为两者都是基于组件的架构. Openbiz的表述层由bizview, bizform和bizform内部的元件组成. 下表中列出Openbiz实施六大优点(参见相对于Struts, 十大喜欢JSF的理由).
| JSF相对于Struts的优势 | Openbiz 的实现 |
| Components(部件) | BizView 和 BizForm 作为持久的界面对象 |
| Render Kits(渲染包) | 连接不同模板到界面对象 |
| Renderers(渲染) | 客户类实施Render()方法 |
| Value Binding(值绑定) | 支持静态和动态值绑定 |
| Event Model(事件模型) | 连接客户端事件到服务器功能 |
| Extensibility(延展性) | 开发商可以把自己的类连接到openbiz对象 |
| 其他四个.... | 不适用 |
类似流行的Hibernate的做法, openbiz利用会话(session)来保持对象的持久性. 不像j2ee的web容器有对象池内存, php每个请求对象兴建和释放(这称为不共享架构). 要保持对象的持久性, openbiz持久对象(bizdataobj,bizform...)将对象状态存入session, 然后重建对象. Also to avoid multiple object instances of same class in the same session, openbiz use ObjectFactory to ensure object singleton. 为防止同一类的对象实例在同一session中出现, openbiz使用ObjectFactory以确保对象的单独性.

Openbiz实现了必要的对象/关系映射(ORM)的功能, 允许Bizdataobj代表数据库表和数据库表间的关系. 下表列出Openbiz ORM的特点
| 灵活的映射 | 每表有一个对象, 或多表一个对象 多对一, 一对多, 多对多, 一对一 |
| 查询设施 | 象SQL一样的l查询语言, 支持SQL函数和操作符, 支持SQL总计功能,和group by, having and order by |
| Metadata 设施 | XML metadata 描述映射 |
Openbiz支持三种网络安全 - 用户认证, 视图控制和数据访问控制. Openbiz主要用途插件服务以控制安全. 这种方案允许用户插入自己的逻辑来服务. 详情将讨论在开发指南-实施认证,视图和数据存取控制.
用户认证流程:

视图准入控制流程:

| 安全 | openbiz执行插件服务 |
| 用户认证 | Openbiz利用认证服务(bin/service/authservice.php)认证的用户名和密码 |
| 基于角色的视图出入管制 | Openbiz用Profile服务(bin/service/profileservice.php)取得用户信息, 其中包括"角色". 然后用access服务(bin/service/accessservice.php)去查询该角色, 以确定用户的视图权限 |
| 基于属性数据存取控制 | Openbiz用Profile服务(bin/service/profileservice.php),以取得用户的概况,包括属性. 然后,基于这些属性,以确定对数据记录浏览/更新/删除的许可. 数据访问权限控制在Bizdataobj. |
Openbiz提供一个PHP框架助你建立复杂的网络应用.
OpenBiz设计作为一个多层结构如下图下文.

通常商业应用可分为3层 - 数据层, 商业逻辑层和表现层. 在openbiz结构中, 其中3层映射到3个软件包. 表现层是执行bizview软件包, GUI层是执行jbform的javascript的软件包. 商业逻辑层是执行Bizdataobj软件包. 数据库处理层是通过第三方的包来实现. 插件服务功能,提供服务组件,可援引双方陈述和数据层对象.
| Package (包) | Class (类) |
| BizSystem | BizSystem - 提供一个全局变量 - 提供get方法为 ObjectFactory, SessionContext, TypeManager, ClientProxy 和 Configuration类 - 提供静态方法访问xml数据,日志和错误报告. |
| SessionContext - Session管理类提供更多方法从session中保存/获得metadata驱动对象的状态, 通过其GetsessionVars|SetsessionVars接口 |
|
| TypeManager - 格式式管理类提供帮助方法格式化数据到用户界面以及解悉界面的输入数据 |
|
| ClientProxy - 它是当作双向代理客户的类. 通过这个类, 其他人可以得到客户输入, 重画客户端或执行客户端的javascript功能. |
|
| Configuration - 这个类提供方法来从config.xml获取数据 |
|
| BizDataObj | BizDataObj - 它是所有数据对象类的基类. 在openbiz1.2之前它被称为BizObj. 因为bizobj指商务对象,但它作为业务数据单元,所以将它改变为BizDataObj. |
| BizRecord - BizRecord类实现对记录的基本功能 |
|
| BizField - BizField类是映射到表格column的逻辑单元 |
|
| BizDataSql - BizObjSql类为Bizdataobj构建sql语句 |
|
| ObjRefernces - ObjReferences包含一组与本BizDataObj相关的其他Bizdataobj |
|
| TableJoins - TableJoins包含一组与本对象连接(join)表格 |
|
| BizView | BizView - BizView是表单的容器类. 它可被视作html网页. |
| BizForm - BizForm是表单的基类. 它是一个html表单, 即包含在一个bizview中. |
|
| RecordRow - RecordRow是FieldControl的容器类 |
|
| ToolBar - ToolBar工具条类. 它包含htmlcontrols |
|
| NavBar - NavBar是导航条类. 它包含按钮 |
|
| HTMLControl - HTMLControl是html元素的基类 |
|
| FieldControl - FieldControl是与bizfield相关的html元素的基类 |
|
| DisplayMode - DisplayMode包含bizform显示模式信息 |
|
| jbForm | jbForm (javascript bizForm) - 客户端处理AJAX的函数调用和回调的基类 |
| ZEND_DB | 这是一个抽象的数据库连接方案,可以连接到不同的供应商的所有主要数据库. 它包含于Zend Framework包内. |

Openbiz客户端浏览器与服务器通过AJAX调用.
Openbiz(2.0或更新版本)是基于php5脚本. 我们推荐平台
安装目录是openbiz,或者你可以配置apache使用别名.
支持浏览器 - IE5.x (或更新版本), Netscape 7.x and Mozillar/FireFox 1.x (或更新版本)
下载zip文件并解压缩到一个目录下 (under web root).
请翻阅openbiz/bin目录下的sysheader.inc, 和demoapp/bin下的 app.inc.
从openbiz2.0rc2中,两个主要的目录包括在软件包. 他们是openbiz核心库和应用演示.
演示应用是一个openbiz的web应用. 因为openbiz提供metadata 驱动架构, bin和metadata 目录是必须的. 其余的目录结构建议,而不是要求. 用户可能有自己的方式来安排web应用结构. 请修改demoapp/bin/app.inc改变常数定义.
正如你观察的bin及metadata结构, 每个bin的子目录下有一个匹配的metadata子目录. 这是代码/metadata匹配原则, 如果你有一个对象的 metadata 在 /metadata/aaa/, 而且对象执行代码是一个用户定义类(不是openbiz核心类), 类代码文件必须在/bin/aaa/目录.
| Openbiz 核心库 |
| openbiz_root/ openbiz_root/ ---bin/ (openbiz core php source - required) ------service/ (openbiz core service library directory) ---document/ (openbiz documents - optional) ------apidoc/ (openbiz core API) ---medata/ (openbiz metadata files - required) ------service/ (service package) ---others/ (third party libraries - optional) ------adodb/ (adodb package) ------Smarty/ (smarty package) |
| 演示应用 |
| demoapp/ (demoapp web pages) ---bin/ (demoapp php source) ------demo/ (demapp demo library) ------shared/ (demoapp shared library) ------service/ (demoapp service library) ---js/ (demoapp javascript files) ---pages/ (demoapp HTML files) ---css/ (demoapp style sheets) ---images/ (demoapp images) ---log/ (demoapp logs) ---medata/ (demoapp metadata files) ------demo/ (demoapp demo package) ------shared/ (demoapp shared package) ------service/ (demoapp service package) ---session (demoapp session files) ---templates (demoapp smarty templates files) ------cpl (demoapp smarty compiled templates) --- ---cfg (demoapp smarty configuration files) ---tmpfiles (temporary files) |
In Unix or Linux box, you need to give write permission to web users on log, metadata, session, tmpfiles and templates directories.在unix或linux里, 你需要将可写权限赋予网络用户对日志, 数据, session, tmpfiles和模板目录.
以下软件包是必要的,他们包括在openbiz软件包
我们建议你安装php优化软件包.
填充演示数据库. 在openbiz根目录寻找gendb.sql, 将它应用到你的数据库. 注意gendb.sql是为mysql数据库的脚本, 请根据不同的数据库类型调整语法.
打开demoapp/clientutil.js. 改变 var binPath = "/demoapp/bin/" ; 到适当的demoapp根下的bin目录. 记得应该是绝对路径, 因此用"/".
打开demoapp/metadata/config.xml, 核实默认数据库正确的属性(如用户名和密码).
然后启动浏览器, 打开http://localhost/demoapp/demo.html
请参阅 http://phpopenbiz.org/document/manual.html#upgrade
请参阅 http://phpopenbiz.org/document/manual.html#svn
OpenBiz是一个完美的工具来帮助你轻松和全面地开发复杂web应用. 基于其3层结构, 你的应用将有一个很清晰的逻辑模式. 它顾及到了面向数据的应用的基本和先进功能. 为了分辨openbiz是否可以帮助建立你的应用程序, 你需要问这些问题:
如果答案是的话, Openbiz就是正确的开发你的应用得的框架,!
当你安装Openbiz软件包时, 你会发现在zip文件有两个主要目录"openbiz"和"demoapp". "openbiz"目录包含了核心openbiz程序和metadata. "demo"目录包含源演示应用(事件管理和日历演示).
上述结构不同于Openbiz RC2.0之前的版本, 在那里你会看到演示应用在openbiz目录里. 为什么openbiz进行了这一转变?
| 自己的开发项目 | 目录 |
| 你的源代码 | your_app_root/bin/ |
| 你的metadata档案 | your_app_root/metadata/your_package/ |
| 你的网站模板 | your_app_root/templates/ |
| 你的网页 | your_app_root/, your_app_root/pages |
| 你的style sheet文件 | your_app_root/css/ |
| 你的图像文件 | your_app_root/images/ |
| 你的日志文件 | your_app_root/log/ |
| 你们的session档案 | your_app_root/session/ |
| 你的临时文件 | your_app_root/tmpfiles/ |
这个结构可以帮助你更有组织地开发openbiz web应用. 你的应用的特定文件都是在一个单独的目录,而不是混在openbiz核心档案. 你可以建立多个web应用基于单个openbiz核心. 你需要做一些额外的步骤, 建立了自己的应用程序目录. 我们建议下列步骤.
在app.inc档案, OPENBIZ_HOME已被确定为openbiz核心库的安装路径. 你的应用程序将使用openbiz核心库以及在metadata目录的核心对象.
RC2的另一个重要变化是metadata和代码必须分别放在对应的/metadata 和 /bin 目录下. 这是代码/metadata匹配原则, 如果你有一个对象的 metadata 在 /metadata/aaa/, 而且对象执行代码是一个用户定义类(不是openbiz核心类), 类代码文件必须在/bin/aaa/目录. 举例来说, /metadata/shared/FMCalendar.xml具有特殊类"FMCalendar", 这"FMCalendar"类的代码必须位于/bin/shared/FMCalendar.php. 如果对象的执行类是openbiz核心类, 没有特别码, 因此就不用在/bin 下写代码. 这个代码/metadata匹配原则给metadata 和代码一个明确结构.
为你的业务数据与关系数据库表建模是你的整个开发的必需的基础建设.
用Openbiz的强大功能来进行系统设计. 你的设计将有
业务需求 -> 界面设计+数据建模+对象设计
用户界面:页面, 表单, 人机互动
数据模型:数据库结构设计
对象设计:
将现有的界面转换为bizviews, bizforms
将现有的数据库表映射到Bizdataobjs
将现有的业务功能变为插件服务
请参阅 http://phpopenbiz.org/document/manual.html#bld_sample
开发商能选择用XML编辑器编辑metadata文件。Openbiz Eclipse插间被推荐为设计和配置工具。参见Openbiz Eclipse插入设计师指南。
在复杂的应用, 用户也许需要建立许多对象, 因此他们有很长的metadata文件名单。如果他们将这些文件放在一个metadata目录之下, 处理metadata文件是一件痛苦的事。从openbiz 1.1, metadata文件可能由包裹名字组织。记住, metadata包裹是不同的以是代码单位的(BizObj, BizView...)包裹。Metadata包裹是一个命名系统, 不同的包裹地对映于\不同的目录。它是象被使用在Java中的包裹概念。
PackageX.PackageY.metaA.xml 指在META_PATH/PackageA/PackageB目录之下的metaA.xml。 META_PATH是metadata根目录。这个宏变量被定义在sysheader.inc 和app.inc 。
我们解释它以演示例子。在您unzip源码之后, 找到在metadata 目录之下演示目录。用文本编辑程序打开FMRegist.xml 文件。您将看见Package="demo" 属性在BizForm 元素。这个属性将说任一类型缺省包裹openbiz 对象是在"demo" 包裹之下。这里openbiz 对象提到以下对象类型。
|
目标类型 |
提到作为属性在metadata文件 |
|
BizObj |
BizForm[BizObj ] |
|
BizForm |
BizView->ControlList->Control[Form ] |
|
BizView |
|
|
BizPopup |
BizForm->BizCtrlList->BizCtrl[SelectBizForm ] |
|
BizFormTree |
同BizForm一样 |
如果对象名不包含小点标志("."), 系统使用定义了在对象根元素包裹属性作为它的包裹。否则, 如果对象名有格式作为aaa.objectname, 系统认为这样的对象在包裹之下"aaa" 并会在aaa 目录之下查找这样的对象。
去回到例子, 您能发现< BizForm Name="FMRegist" Package="demo"... BizObj="BORegist"... >, < BizCtrl Name="reg_attdln"... SelectBizForm="AttendeePopup"... > 和< BizCtrl Name="reg_fee"... SelectFrom="Selection(Fee)"... > 。他们全都个用途缺省包裹, 因此系统将设法寻找metadata 文件作为 demo/BORegist.xml 、 demo/AttendeePopup.xml 和 demo/Selection.xml 。
如果您想要提到对象在其它包裹之下, 请增加包裹名字作为对象名的前缀。通知, 有Selection.xml 在/demo 目录之下并且其它Selection.xml 在/design 目录之下, 他们属于不同的包裹。在FMRegist, 包裹是"演示", 您能使用< BizCtrl... SelectFrom="design.Selection(Mode)" ... > 配置价值是从"design/Selection.xml 的" "方式" 元素的comboBox 。
您无法提到一个对象在另外应用。但您能提到任一个对象在openbiz 核心应用。例如, 核心应用有提到对象在metadata/shared/ 目录之下。Openbiz 设法找出对象同样应用和然后核心应用。如果对象不被发现, 它报告错误。
如果你有一个非常复杂的应用,你要重用现有对象,以不同的地方,但是你要表现的对象在不同的情况下回有不同,. 继承对象将解决以上问题. 由于openbiz框架的对象映射到metadata数据文件, 继承对象就成为数据文件继承.
指定对象属性, InheritFrom = "父母对象名" 。例如, 在演示应用, BOEventX 有< BizObj Name="BOEventX" Description="Event BizObj Extended BOEvent" Package="demo" Class="BizObj" InheritFrom="demo.BOEvent"... > 。这表明是BOEventX 被继承从BOEvent 。
Metadata 文件继承类似于以类继承在编程语言, 子对象可能继承(如果没定义在子对象, 而且定义在父对象) 或覆盖(如果同样属性被定义在子对象和父对象) 父对象的属性。
| 能有继承的对象类型 | 什么可能被继承或覆盖 | 什么无法被继承- 必须被指定在子metadata 文件中 |
| BizObj | 对象属性: 描述, DBName, Table, SearchRule, SortRule, OtherSQLRule, CacheMode
对象BizFieldList: BizField |
对象属性: Name, Package, Class, InheritFrom |
| BizForm | 对象属性: Description, jsClass, Title, BizObj, PageSize, Width, Height, SearchRule
Object BizCtrlList: BizCtrl |
对象属性: Name, Package, Class, InheritFrom |
为了增加metadata 配置的灵活性, Openbiz 在metadata 文件接受简单表达式语言。如果声明有 {expr} 样式, expr 将被评估作为简单的表示。 基本上, 简单表达式是返回值的一个PHP 语句。如果用户需要的复杂逻辑无法被一个简单表达式表示, 他们可将特别代码写在用户定义的类里。
简单表达式将支持metadata 属性动态值捆绑。在metadata 文件中用户能在以下地方使用简单表示。
简单表达式语言定义以下字符:
简单表达式语言提供以下操作符:
得到metadata 对象变量的句法 变量 实现 例子 @object_name:property_name 得到指定的对象的指定的内容 Call object->GetProperty ($propname) @BOEvent:Name
@FMEvent:Title@object_name:*[child_name].property_name 得到指定的对象的指定的子元素的内容 Call object->GetProperty ($propname), where $propname="*[child_name]", to get the child object.
Then call child_object->GetProperty($propname)@BOEvent:Field[Id].Value
@FMEvent:Control[evt_id].Value@:property_name or
@this:property_name得到本对象指定的内容 ("本" 对象是被定义在metadata 文件中的对象) Call this->GetProperty ($propname) In BOEvent, @:Name or @this:Name means getting the "Name" property of BOEvent. @:*[child_name].property_name or
@this:*[child_name].property_name得到本对象的指定的子元素的内容 Call this->GetProperty ($propname), where $propname="*[child_name]", to get the child object.
Then call child_object->GetProperty($propname)In BOEvent, @:Field[Id].Value or @this:Field[Id].Value means getting the "Id" field value of BOEvent. [field_name] 得到本BizDataObj 指定的BizField 的值 。 Call object->GetProperty ($field_name) to get the child BizField object.
Then call field_object->GetProperty("Value")In BOEvent, [Id] means getting the "Id" field value of BOEvent. @object_name:param[param_name] or
@:param[param_name]得到这个对象的指定的参数值 Call object->GetProperty ($propname), where $propname="param[param_name]" @:param[Evt_Id] @profile:property_name 得到用户概况属性 User profile is provided with ProfileService. @profile:ROLEID 从上述的实现可看出, 如果重写 GetProperty() 方法, 开发商可能增加支持更多属性。GetProperty() 的输入可能是支持由顾客代码的"property_name" 或"* [ child_name ]" 或其他。
简单的表示语言并且允许开发商使用所有全局变量由PHP 支持。请阅读 http://us2.php.net/manual/en/reserved.variables.php
开发商可以在简单表达式中调用所有PHP 函数。如果包含函数的文件被包括了, 用户定义的函数可能被调用。例如, 如果metadata 对象A 是一个用户类, 类文件是包括A_help.inc 的A.php。在这种情况下, 您能在简单表达式中调用定义在A_help.inc函数。
BizDataObj xml 的DTD 文件被列出在附录A.1
Openbiz 映射数据库表格到BizDataObj 对象。这个章节介绍BizDataObj与表格映射的概念, 下个章节"ORM" 有映射的配置的全面详细。BizDataObj 必须有表格名字和表格column 和 BizDataObj fields的映射。
<BizDataObj Name="BizDataObjName" Table="TableName" ...>
<BizField Name="FieldName" Column="ColumnName"....>. 一个BizFields 必须有命名作为"Id" 。这必需的。"Id" 通常映射到表的主键.
用户能将由数据库引擎提供的SQL function设给BizField。句法是< BizField Name="FieldName" Column= "" SQLExpr="FUNC([FieldName1]... [FieldName2 ]...)"> 。要保证Column属性是空的。例如: < BizField Name="FullName" Column= "" SQLExpr="CONCAT([FirstName ], ' ', [LastName ])"... > 。请注意SQLExpr 是询问相关的属性。[ FieldName ] 是询问语言的句法。
<BizField Name="FieldName" Column="ColumnName" DefaultValue="default_value">. 使用DefaultValue 属性, 当dataobject 创造一个新纪录时, 会将缺省值设给BizField。
Openbiz 用户不用担心组成的复杂的SQL 声明。BizDataObj 支持在对象水平更加直观的查询语言。基本的句法是"[FieldName] opr 'Value' AND/OR [fieldName] opr 'Value'...". 这里"opr" 是SQL 操作符。在运行时, openbiz 将[ FieldName ] 改变为column名字而产生SQL 声明。Openbiz 并可以将表格关系放入SQL中。
在SearchRule中指定缺省询问
例子: <BizObj Name="BOCalendar" Description="Calendar BizObj" Package="shared" Class="MyClass" Table="calevts" SearchRule="[Start]>'1999-10-20'" ...>
在SortRule中指定缺省排序
例子: <BizObj Name="BOCalendar" Description="Calendar BizObj" Package="shared" Class="MyClass" Table="calevts" SortRule="[Start] ASC" ...>
在OtherSQLRule中指定另外的SQL 声明
例子: <BizObj Name="BOCalendar" Description="Calendar BizObj" Package="shared" Class="MyClass" Table="calevts" OtherSQLRule = "GROUP BY [EvtId] HAVING [Fee]>10" ...>
BizField 支持以下的数据类型和格式。
| 类型 | 格式 | 句法 | 格式例子 |
| 文本 | 无 | 文本是默认类型 | |
| 数字 | 格式由printf 支持 | < BizField... Type="Number" Format="%..."... > | %5.2f 打印浮点数字 |
| "Int" - 整数格式(与地点相关) | < BizField... Type="Number" Format="Int"... > | 如果locale=enu, 12345.678 被显示作为12,346 | |
| "Float" - 浮点格式(与地点相关) | < BizField... Type="Number" Format="Float"... > | 如果locale=enu, 12345.678 被显示作为12,345.68 | |
| 日期 | 在缺省只读方式下, 日期可能根据 数据格式被格式化。 | < BizField... Type="Date" Format="date format"... > | 6/21/2003 可能被格式化 %A, %b %d %Y - 星期六, 2003 年6月21 日如果系统地点是enu |
| Datetime | 在缺省只读方式下, 日期可能根据 数据格式被格式化。 | < BizField... Type="Datetime" Format="datetime format"... > | 6/22/2003 9:30am 可能被格式化 %m/%d/%Y %H:%M:%S - 06/22/2003 09:30:00 如果系统地点是enu |
| 货币 | 格式化(与地点相关) | < BizField... Type="Currency" Format="Currency"... > | 1456.89 被格式化作为$1,456.89 (enu) 1456.89 被格式化作为F1 456,89 (fra) |
| 电话 | 格式化(根据指定的mask #) | < BizField... Type="Phone" Format="mask string"... > | 1234567890 被格式化 mask=(###) ###-####, phone=(123) 456-7890 mask=###-###-####, phone=123-456-7890 |
| 如果一个电话号码从开始"*", 它代表国际电话号码, 它不会被格式化 | * 123 4567890 是国际数字 | ||
| Blob/Clob | 无 | < BizField... Type="Blob"... > < BizField... Type="Clob"... > |
| 检验类型 | 例子 |
| Required - 表明领域无法是空的 | < BizField Name="Name" Required="Y" Column="NAME"/> |
| Validator - 简单表达式 | < BizField Name="Fee" Type="Currency" Format="Currency" Validator="{[Fee]>=15}" Column="FEE" > |
为支持O/R 映射, TableJoin 和ObjectReference 被引入到BizDataObj metadata 文件。
用下面的例子来了解O/R 映射:

attendee:regist = 1:M (一对多), regist:attendee = M:1 (多对一)
events:regist = 1:M (一对多), regist:events = M:1 (多对一)
attendee:events = M:M (多对多)
映射表格到BizDataObj, 用户只需要在metadata配置BizFieldList。例如:
<BizDataObj Name="BOEvent" Description="Event BizDataObj" Package="demo" Class="BizDataObj" Table="events" ...>
<BizFieldList>
<BizField Name="Id" Column="SYSID"/>
<BizField Name="Name" Column="NAME"/>
</BizFieldList>
</BizDataObj>
从Openbiz 2.1RC, BizDataObj 支持多种id 生成算法。增加一个BizDataObj 属性
IdGeneration="Openbiz|Identity|Sequence:seqname|GUID|UUID|Other...".
| IdGeneration | 主键(Primary Key column) 生成方法 | 支持的数据库类型 |
| Openbiz (default) | 用"ob_sysids"表来生成Id. "ob_sysids"存储表格的 PK column. | 适用于所有数据库类型 |
| Identity | 主关键字专栏由数据库引擎生成。 在SQL 服务器里, Id 叫做"Identity" column, 或在MySQL 叫做"自增" 专栏。 |
MySQL, SQL Server, Sybase, DB2 |
| Sequence:seqname | 主关键字栏由数据库序列生成。"seqname" 是序列名字被使用生成PK 。 | Oracle, PostgreSQL, DB2 |
| GUID | GUID主关键字栏是数据库生成的GUID | MySQL, SQL Server, Oracle |
| UUID | 主关键字栏以php uuid()生成 | 适用于所有数据库类型 |
| Other | Developers can write customer specific Id generation algorithm by modifying function GetNewID(...) in genIdService class under openbiz/bin/service/genIdService.php
开发商能写客户具体Id 生成算法 - 修改在genIdService 组在openbiz/bin/service/genIdService.php 之下的 GetNewID(...) |
由客户决定 |
In Openbiz 2.1, BizDataObj supports composite key. This feature would be useful when working with legacy database tables who does not have single primary key column. The syntax of BizDataObj whose Id field maps >2 primary key columns is:
在Openbiz 2.1, BizDataObj 支持组合关键字。这个特点会用在老式的没有唯一主关键字栏的数据库系统。BizDataObj 的Id 域映射到>2个主关键字栏. 句法是:
<BizDataObj Name="" Package="" Class="" ... IdGeneration="None">
<BizField Name="fpk1" Column="PK1"/>
<BizField Name="fpk2" Column="PK2"/>
<BizField Name="Id" Column="PK1,PK2" />
...
用户能通过Join映射多表到BizDataObj。这就是说基本表中的外键 (Foreign Key) column指到被Join的表一个column中. 例如,
<BizObj Name="BORegist" Package="demo" Class="BizObj" Table="regist" ...>
<BizFieldList>
<BizField Name="Id" Column="SYSID"/>
<BizField Name="EvtId" Column="EVENT_ID"/>
<BizField Name="AttendeeId" Column="ATTENDEE_ID"/>
<BizField Name="AttdLName" Join="attendee" Column="LASTNAME"/>
<BizField Name="AttdFName" Join="attendee" Column="FIRSTNAME"/>
</BizFieldList>
<TableJoins>
<Join Name="attendee" Table="attendee" Column="SYSID" ColumnRef="ATTENDEE_ID" JoinType="INNER JOIN"/>
</TableJoins>
| Join 属性 | 描述 |
| Name | join 的名字. |
| Table | joined 表名 |
| Column | joined column 名字 |
| JoinRef | 如果JoinRef 是空的, 被joined表连到基本表。用户能指定JoinRef 在2 级 join。 |
| ColumnRef | ColumnRef 指到基本表的column (或 JoinRef 表). |
| JoinType | INNER JOIN, LEFT JOIN, RIGHT JOIN, or FULL OUTER JOIN. |
询问SQL类似于 "SELECT ... FROM BaseTable INNER JOIN JoinedTable ON BaseTable.ColumnRef=JoinedTable.JoinedColumn ...". 在上述例子, SQL 是
SELECT T0.SYSID, T0.EVENT_ID, T0.ATTENDEE_ID, T1.LASTNAME, T1.FIRSTNAME
FROM regist as T0
INNER JOIN attendee as T1 ON T0.ATTENDEE_ID = T1.SYSID
- 关于JoinRef更多解释
JoinRef 支持 cascade-join. 例如, 表 A join B, 表 B join C. 表 A 和 C 通过 B join在一起. User 可能使用以下的方式连接C 和A 。
<TableJoins>
<Join Name="join_b" Table="B" Column="B_PK" ColumnRef="A_FK_B" JoinType="LEFT OUTER JOIN"/>
<Join Name="join_c" Table="C" JoinRef="join_b" Column="C_PK" ColumnRef="B_FK_C" JoinType="LEFT OUTER JOIN"/>
</TableJoins>
在BizDataObjs 之间多对一关系
在二个表之间多对一关系意味着表1 包含一个column 指向表2 的 key/unique column。映射在二个BizDataObjs 之间这样的关系, 要用在ObjectReference 部分定义的一个对象。例如,
<BizObj Name="BORegist" Package="demo" Class="BizObj" Table="regist" ...>
<BizFieldList>
<BizField Name="Id" Column="SYSID"/>
<BizField Name="EvtId" Column="EVENT_ID"/>
<BizField Name="AttendeeId" Column="ATTENDEE_ID"/>
<BizField Name="AttdLName" Join="attendee" Column="LASTNAME"/>
<BizField Name="AttdFName" Join="attendee" Column="FIRSTNAME"/>
</BizFieldList>
<TableJoins>
<Join Name="attendee" Table="attendee" Column="SYSID" ColumnRef="ATTENDEE_ID" JoinType="INNER JOIN"/>
</TableJoins>
<ObjReferences>
<Object Name="BOEvent" Description="" Relationship="M-1" Table="events" Column="SYSID" FieldRef="EvtId"/>
</ObjReferences>
</BizObj>
| 对象 属性 | 描述 |
| Name | 被提到的BizDataObj 的名字 |
| Description | |
| Relationship | dataobj 之间的关系 |
| Table | 被提到的dataobj的表 |
| Column | 被提到的dataobj的表的column |
| FieldRef | 基本表中映射到 foreign key column 的 field |
从父dataobj调用GetRefObject($objame) 可以得到ObjReference 中的对象.
在二个表之间一对多关系意味着表2 包含一个 column 指向表1 的 key/unique column。映射在二个BizDataObjs 之间这样的关系, 要用在ObjectReference 部分定义的一个对象。例如,
<BizDataObj Name="BOEvent" Description="Event BizDataObj" Package="demo" Class="BizDataObj" Table="events" ...>
<BizFieldList>
<BizField Name="Id" Column="SYSID"/>
<BizField Name="Name" Column="NAME"/>
</BizFieldList>
<ObjReferences>
<Object Name="BORegist" Description="" Relationship="1-M" Table="regist" Column="EVENT_ID" FieldRef="Id" CascadeDelete="Y"/>
</ObjReferences>
</BizDataObj>
| Object Attribute | Description |
| Name | 被提到的BizDataObj 的名字 |
| Description | |
| Relationship | dataobj 之间的关系 |
| Table | 被提到的 dataobj的表 |
| Column | 被提到的 dataobj的表的 column. 该 column 包含指到基本表中的 foreign key |
| FieldRef | 基本表中映射到 foreign key column 的 field |
| CascadeDelete | 表明是否在基本表里删除一个纪录将导致在被提到的表里所有相关纪录的删除。 |
从父dataobj调用GetRefObject($objame) 可以得到ObjReference 中的对象.
- 在BizDataObjs 之间一对一关系
一对一关系是多对一关系的一种特殊情况
在二个表之间多对多关系意味着一个 intersection 表 (又叫作 cross reference table, 或 correlation table) 包含指向表1和表2的 key/unique columns. 映射在二个BizDataObjs 之间这样的关系, 要用在ObjectReference 部分定义的一个对象。例如,
<BizDataObj Name="BOEvent" Description="Event BizDataObj" Package="demo" Class="BizDataObj" Table="events" ...>
<BizFieldList>
<BizField Name="Id" Column="SYSID"/>
<BizField Name="Name" Column="NAME"/>
</BizFieldList>
<ObjReferences>
<Object Name="BOAttendee" Description="" Relationship="M-M" Table="attendee" Column="SYSID" FieldRef="Id" CascadeDelete="Y" XTable="regist" XColumn1="EVENT_ID" XColumn2="ATTENDEE_ID"/>
</ObjReferences>
</BizDataObj>
| Object Attribute | Description |
| Name | 被提到的BizDataObj 的名字 |
| Description | |
| Relationship | dataobj 之间的关系 |
| Table | 被提到的 dataobj的表 |
| Column | 被提到的 dataobj的表的 column. 该 column 包含指到基本表中的 foreign key |
| FieldRef | 基本表中映射到 foreign key column 的 field |
| CascadeDelete | 表明是否在基本表里删除一个纪录将导致在被提到的表里所有相关纪录的删除。 |
| XTable | intersection 表名 |
| XColumn1 | 指到基本表foreign key 的 intersection 表 column |
| XColumn2 | 指到被提到基本表foreign key 的 intersection 表 column |
| XDataObj (New in 2.1) | BizDataObject - 它的基本表是 intersection table (XTable). |
从父dataobj调用GetRefObject($objame) 可以得到ObjReference 中的对象.
BizView metadata DTD 文件可能被发现在附录A.2 。
BizForm metadata DTD 文件可能被发现在附录A.2 。
BizView 是包含多个BizForms 和其它HTML 元素的物理网页。它的布局根据smarty 模板 。BizView 定义BizForms 布局并且关系在BizForms 之间。
- BizForms 显示BizDataObj 关系
如果超过一个BizForm 被安置在BizView 并且在BizView指定他们的父子关系, BizForms 将回显示BizDataObj 的关系。
<BizView Name="EventView" ...>
<ControlList>
<Control Name="fm_event" Form="FMEvent" SubCtrls="FMAttendeeChild"/>
<Control Name="fm_attd" Form="FMAttendeeChild"/>
</ControlList>
</BizView>
SubCtrls 属性句法是 SubCtrls="childform1_name;childform2_name;...".它告诉子form 其父form 的名字, 这意味子form数据根据父form 的变动而改变。
由于BOEvent 和BOAttendee 有多对多关系, event form 和 attendee form 将是M-M 的关系。他们在用户界面显示数据关系。
- Event View 例子:
EventView (Event-Attendee as M-M)
|
Openbiz BizForm 可分成三部份 - 数据部分、工具栏和导航条。
这BizForm 的样品布局:
工具栏 导航条
|
由BizForm表现BizDataObj
BizForm 代表数据从BizDataObj 。BizForm 定义在BizForm中的BizCtrls 和在BizDataObj中的BizFields 之间的映射。例子,
<BizForm Name="FMRegist" ... BizObj="BORegist" ...>
<BizCtrlList>
<BizCtrl Name="reg_id" FieldName="Id" DisplayName="Registration Id"/>
<BizCtrl Name="reg_evtid" FieldName="EvtId" DisplayName="Event Id"/>
<BizCtrl Name="reg_attdid" FieldName="AttendeeId" DisplayName="Attendee Id"/>
<BizCtrl Name="reg_attdfn" FieldName="AttdFName" DisplayName="First Name"/>
<BizCtrl Name="reg_attdln" FieldName="AttdLName" DisplayName="Last Name"/>
</BizCtrlList>
</BizForm>
HTMLControl 或BizCtrl 可以指定元素类型和属性来, 以各种各样的HTML 元素表现它的数据。HTML 元素被显示在edit/query 模式下
|
BizForm 中 HTMLControl 元素属性 |
||||||||
| Type | Width | Height | HTMLAttr* | Style** | SeclectFrom | Caption | Image | 评论 |
| Text | x | x | x |
x | 文本输入。默认类型 | |||
| Textarea | x | x | x | x | 多行的文本输入 | |||
| RichText | x | x | x | x | ||||
| ListBox | x | x | x |
x | x |
ListBox or ComboBox | ||
| CheckBox | x | x | x | x | x |
复选框 | ||
| Radio | x |
x | x | x | x |
Radio 按钮 | ||
| HTMLButton | x | x | x | x | x | 标准HTML 按钮 | ||
| SubmitButton | x | x | x | x | x | 标准HTML Submit 按钮 | ||
| ResetButton | x | x | x | x | x | 标准 HTML Reset 按钮 | ||
| Password | x | x | x | x | HTML password | |||
| Button | x | x | x | x | x | x | OpenBiz 图象按钮 | |
| Date | x | x | x | x | ||||
| Datetime | x | x | x | x | ||||
| HTMLBlock | x | x | x | x |
HTML block | |||
| File | x | x | x | x | 文件控制上装文件 | |||
* HTMLAttr 域可包含任一个合法的HTML 元素类型的HTML 属性
** Style 域可包含所有合法的样式 (css)
HTMLAttr="maxlength=N" 限制用户能输入在文本控制字符的最大数字
由缺省展示comboBox 。如果HTMLAttr="size=N", 显示N 列listbox
SelectFrom="XmlFile(Key)" 意味控制是listbox 或radio button. 数据是在XmlFile文件中所有的"Key" 元素
SelectFrom="Value" 意味这当用户检查复选框时, 复选框返回"Value"
By default the radion buttons are arranged horiztionally. If Width="1", you can force them arranged vertically.
缺省radio 按钮横向安排。如果Width="1", 您可能迫使他们垂直安排了
在 HTML block 使用"<" and ">" , 必须由"<" 和 ">"替换。参见 http://www.w3schools.com/html/html_entities.asp 以获得详情。
Openbiz rich text editor 主要使用Kevin Roth http://www.kevinroth.com/rte/demo.htm的代码 (LGPL license) . 感谢他的优秀工作。它支持IE5.5+ 并且Firfox 1.x. 如下是screenshot 。

Openbiz 2.1 使用由dynarch.com 提供的开放源码DHTML calendar 1.0 (LGPL) . DHTML calendar 的文档资料在 http://www.dynarch.com/demos/jscalendar/doc/html/reference.html. 多谢 Nik Chankov 帮助集成的openbiz 与 DHTML calendar. Openbiz 使用系统样式日历

BizCtrl 另外的属性
当HTML 元素可能触发象onclick 和onblur的事件, 我们可以将事件处理函数联系各HTML 控制或BizCtrl 的事件。事件处理被定义在以下句法。
<Control Name="ControlName" Type="ControlType">
<EventHandler Name="ehName" Event="eventName" Function="..." FunctionType="..." PostAction=""/> +
</Control>
可以联系更多的事件处理函数到一个控制上。这是一个在2.1的新特点。在Openbiz 2.0, 一控制可能有只一个事件处理函数。2.1, 函数和FunctionType 属性从控制元素被移动到控制元素的EventHandler 元素中。
- Event 是HTML 元素事件名字。参见 http://www.w3.org/TR/REC-html40/interact/scripts.html, 18.2.3 Intrinsic events。
- Function 服务器端应该有一个对应的BizForm 方法。当请求达到BizController, 它会调用正确的BizForm 方法。如果方法不存在, 错误返回。Function 的句法:
<EventHandler ... Function="objectName.methodName(arg1, arg2...)" .../>.
ObjectName 可能是空的, 这意味它调用当前的BizForm 方法。例如, < EventHandler... Function="SaveRecord()".../>. 用户能只调用基于metadata 文件对象的方法。这些对象包括BizForm 、BizDataObj 、BizView 和PluginService 。BizForm 方法和PluginService 方法被推荐为从客户端可调用的方法。
- FunctionType 可能是 RPC 或 Page 或 Form 或 Popup.
| FunctionType | 解释 | 例子 |
| RPC | 方法在服务器端由HTTPRequest (AJAX)调用 。RPC 是缺省值 | New record button: <Control Name="btn_new" Function="NewRecord()" FunctionType="RPC"/> |
| Page | 方法在服务器端由页刷新调用, Form数据不传到服务器端 | Export button to bring up a file save dialog in the page <Control Name="btn_export" Function="CallService(ioService,exportXML)" FunctionType="Page"/> |
| Form | 方法在服务器端由Form submission调用 | Save button when there's file to upload in the form: <Control Name="btn_save" Function="SaveRecord()" FunctionType="Form"/> |
| Popup | 方法在服务器端调用, 返回的页被画在一个弹出式窗口中 | Excel output button to show excel format in a popup: <Control Name="btn_excel" Function="CallService(excelService,renderHTML)" FunctionType="Popup"/> |
- ShortcutKey 将一个热键联系到函数。 "在BizForm键盘航海"会有解释 。
- PostAction 在函数调用之后, 重定向到page/view 。"控制页面航海"会有解释
Openbiz 2.1RC 增加一个非常重要特点- 支持BizForm键盘导航。一旦热键被定义在BizForm, 用户能使用键盘对浏览纪录和页, create/edit/delete 纪录。
热键被定义在BizForm metadata 文件。控制的EventHandler 的ShortcutKey 属性可以将热键和函数联系在一起。句法是<Control Name="" Function="" ShortcutKey="key_combination".../> 。BizForm 只认可被定义在工具栏和Navbar 控制上的热键。
Openbiz 认可的热键包括:
| 输入的键 | 使用在ShortcutKey 属性中键的名字 |
| 0,1,...9 | 0,1,...9 |
| a,b,...z or A,B,...Z | A,B,...Z |
| Ctrl key | Ctrl |
| Shift key | Shift |
| Alt key | Alt |
| Enter key | Enter |
| Escape key | Escape |
| Page up key | PageUp |
| Page down key | PageDown |
| Left arrow key | Left |
| Right arrow key | Right |
| Up arrow key | Left |
| Down arrow key | Down |
| Insert key | Insert |
| Delete key | Delete |
开发商可能配置Ctrl 并且/或者 Shift 并且/或者 Alt 和其它键, 用"+" 连接他们。注意不要与缺省浏览器热键冲突。参见 http://www.mozilla.org/support/firefox/keyboard 为不同的浏览器的热键。
参见在demoapp/metadata/demo/FMEvent.xml 的热键例子。这个BizForm 支持以下热键:
| 热键 | 执行命令 |
| Ctrl+Shift+Right | go to next page |
| Ctrl+Shift+Left | go to previous page |
| Ctrl+Shift+Down | go to next record |
| Ctrl+Shift+Up | go to previous record |
| Ctrl+Shift+N | create a new record |
| Ctrl+Shift+E | edit the selected record |
| Delete | delete the selected record |
| Ctrl+Shift+Q | switch to search record mode |
| Enter | run search, or save record |
| Escape | cancel search or cancel editing |
| Ctrl+Shift+C | copy the selected record |
| Ctrl+Shift+R | refresh form with default query |
以复杂Form 中, 有通常一些控制依靠其它控制的值。当父控制变化, 它的子控制相应地变化。这是所谓的Form 控制的相互依赖。
在表示语言帮助下, 控制关系可被指定在BizForm metadata 文件中。在event handler帮助下, 在父控制变化事件将导致它的子控制的动态变动。
在demoapp/metadata/demo/FMFieldDepTest.xml 之下用一个例子

第一combobox 是主控制。根据它的值,
- 第2 控制将使能被enabled 或 disabled (BizForm 配置)
- 第3 控制将掩藏或将被显示 (BizForm 配置)
- 第4 控制将有不同的名单 (BizForm 配置)
- 第5 控制将改变价值和颜色当monuseover 第主控制时 (客户端 jbForm 的子类)
用来选择记录的popup BizForm 的配置
用户能从一个另外Form中选择纪录 (见以下例子):
有二种方式配置记录选择的popup BizForm 。
配置HTML 控制显示popup 形式, 用户在控制功能属性设置"showpopup($popupFormName)" 和FunctionTarget="Popup" 。这种配置可能被使用来在子Form中选择子纪录(M-1或M-M关系) 。
<Control Name="btn_new" Caption="Add" Type="Button" Function="ShowPopup(demo.FMAttendeePopup)" FunctionTarget="Popup"/>
On the popup form, add a button to call AddToParent() to add the current selected record to the parent form (the form trigger the popup).
在popup form, 增加一个按钮来调用AddToParent(), 选择的纪录到父form 。
配置BizCtrl 显示popup 从, 用户ValuePicker 属性
<BizCtrl Name="reg_attdln" FieldName="AttdLName" DisplayName="Last Name" ValuePicker="FMAttendeePopup"/>
在popup form, 增加一个按钮来调用JoinToParent(), 选择的纪录到父form 。
You can user ValuePicker attribute to allow users to click the icon to show the picker popup window. Users may want to type in the value in the control and system will automatically pick the right record according to the user input. Openbiz supports this feature by BizForm's AutoPickValue($ctrlname) method. To configure auto picker.
您能用ValuePicker 属性允许显示用户选择器popup 窗口。用户也许想要在控制键入值并且系统自动地根据用户输入选择正确的纪录。Openbiz 由BizForm 的autopickvalue($ctrlname) 方法支持这个特点。配置自动选择器。
<BizCtrl Name="reg_attdln" FieldName="AttdLName" DisplayName="Last Name" ValuePicker="FMAttendeePopup">
<EventHandler Name="onchange" Event="onchange" Function="AutoPickValue(reg_attdln)" />
</BizCtrl>根据用户输入, 行为被描述在以下表格:
用户输入 行为 not 空 以 [field] LIKE 'input_value%' 的 searchRule 来查询 valuepicker BizForm 的 DataObj. 根据询问结果:
- 如果唯一纪录返回了, 以返回值自动填入所有相关控制中
- 如果纪录没有返回, 显示没有searchRule的值选择器popup
- 如果多个纪录返回了, 显示加上searchRule的值选择器popup
您能配置BizCtrl 与一个链接(drilldown 链接), 这个链接指到其他的view。
在BizForm, 设置BizCtrl 的一个DillDownLink 属性。句法是
DrillDownLink="OtherView,OtherBizForm.OtherBizCtrl=MyBizCtrl".
OtherView - drilldown 链接指到其他的view的名字
OtherBizForm - 在OtherView中的一个独立BizForm, 不是其他BizForm 的子form
OtherBizCtrl - OtherBizForm 的一个 BizCtrl
MyBizCtrl - 该BizForm 的一个 BizCtrl
例子: <BizCtrl Name="reg_attdln" FieldName="AttdLName" DisplayName="Last Name" ValuePicker="FMAttendeePopup" DrillDownLink="AttendeeView,FMAttendee.attd_id=reg_attdid"/>.
从comboBox 或ListBox选择域数据
- 捆绑静态列表和comboBox
在您的BizForm, 您为BizCtrl设置SelectFrom="Selection(Fee)", 意味这comboBox域控制的数据是Selection.xml 文件"Fee" 元素的列表 。请在演示FMRegist.xml中参见例子 - BizCtrl reg_fee 被定义为comboBox。
<Selection>
<Fee Value=""/>
<Fee Value="15"/>
<Fee Value="20"/>
</Selection>
并且, 您能给值和文本。如果只给值, openbiz 使用值作为显示文本。
<Selection>
<ChartOption Value="AAA" Text="BarLine Chart"/>
<ChartOption Value="BBB" Text="Pie Chart"/>
<ChartOption Value="CCC" Text="GroupBar Chart"/>
</Selection>
您能选择的您自己的xml 文件。
- 捆绑动态列表(Table column) 和comboBox
在您的BizForm, 您为BizCtrl设 SelectFrom="BizDataObjName[BizFieldName ]" , 这意味comboBox 绑定了BizObjName 中BizFieldName 对应的 table column。避免同样的值出现在comboBox, 您需要确定BizObj 询问返回归一张独特的list。
Openbiz 也支持格式 SelectFrom="BizDataObjName[BizFieldName4Text:BizFieldName4Value ]" 。这样一来用户能在comboBox 中显示BizFieldName4Text 为文本, 而BizFieldName4Value 为值。
SearchRule 可以用在SelectFrom 中, 句法为 SelectFrom="BizDataObjName[BizFieldName4Text:BizFieldName4Value ], SearchRule_of_the_BizDataObj"。例如, <BizCtrl Name="" ... SelectFrom="BOEvent[Name], [Name] LIKE '%Soc%'"/>.
Openbiz 有显示方式的一个独特的概念。BizForm 可能有超过一个显示方式。各个显示方式基本上是BizForm 的rendering 方式。Bizform 对BizDataObj 数据对用不同的显示方式显示.
- BizForm的显示方式
显示方式被指定在< BizForm metadata 文件的DisplayModes > 部分。您能将各个方式同smarty 模板联系在一起。为细节参见 创建 view 和 form web templates.。
通常BizForm 可能有READ, NEW, EDIT, QUERY 显示方式。但显示方式没有限制。例子是在/demoapp/metadata/shared/FMCalendar.xml 之下。它有显示方式"LIST", "DAY", "WEEK", "MONTH"。
在显示方式之间切换需要调用BizForm 方法setdisplaymode($mode)。代码在各个显示方式被运用时可实现特别逻辑。
各控制或BizCtrl 有DisplayMode 属性。您能设置DisplayMode = "MODE1|MODE2|... "。例如, < BizCtrl Name="LastName"... DisplayMode="EDIT|NEW"/>, 然后LastName 只被显示在EDIT 和NEW 模式。
- 在action 被执行后进行页面重定向
It's very common that users click on a button to trigger an action on server side and after the action is finished the page is redirected to another page. Page redirection can be specified as a post action in BizForm metadata file. The syntax is
用户点击按钮在服务器端触发一次action 并且在action 被执行后进行页面重定向, 这是非常普遍的。页面重定向可被指定在BizForm metadata 文件的post action中。句法是
<EventHandler Name="..." Function="..." PostAction="url|view"/> PostAction 可接受 url:url_string 或 view:view_name.
例子在 login form demoapp/metadata/shared/FMAuth.xml
<Control Name="btn_submit" Image="" Caption="Submit" Type="HTMLButton" Function="Login()" PostAction="url:login.php?login=success"/>
- 错误页和错误信息
如果执行中有错误, 应用会返退错误页或显示错误弹出窗口到浏览器
数据输入和输出的支持对离线用户很重要。离线用户通常在他们的膝上计算机执行应用在, 然后再与服务器数据库进行同步。Openbiz 提供的输入和输出支持用以下方式:
Data export - implemented in exportXML method of ioService. The exported xml file has format as
数据输出 - 被实施在ioService exportXML 方法。被输出文件是xml 格式
<BizDataObj Name="demo.BOAttendeeX">
<Record>
<Field Name="field name" Value="field value" /> *
</Record>
</BizDataObj>
数据输入 - 被实施在ioService importXML 方法。xml 文件输入有如上所述同样格式。
输入和输出按钮被配置在FMAttendee form 中。输入按钮直接地调用ioService 的exportXML 方法, 而输出按钮则弹出一个popup 窗口来问用户被输入的文件名。细节请参见demoapp/metadata/demo/FMAttendee.xml。
可以增加更多export/import 方法在ioService 支持以其它文件类型。
文件上载的支持在openbiz shared 包裹里。Metadata 文件在demoapp/metadata/shared/FMAttachment.xml, 它的类文件在demoapp/bin/shared/FMAttachment.php 。
上载文件, 用户需要配置BizCtrl 类型为"File" 。它映射对BizField 类型为"Blob" 。
下载文件, 用户需要配置BizCtrl 的Function 为download($record_id) 。下载方法被实施在FMAttachment 类。
参见FMAttachement 类和metadata 为细节。
请参阅Openbiz开发指南
| 库名 | URL | 描述 | License |
| Smarty | http://smarty.php.net | 模板引擎 | LGPL |
| Adodb | http://adodb.sourceforge.net | 数据库抽象库 | BSD |
| PHPMailer | http://phpmailer.sourceforge.net | 电子邮件库 | LGPL |
| jsval | http://jsval.fantastic-bits.de | 客户端数据有效性验证 | LGPL |
| jscalendar | http://www.dynarch.com/projects/calendar | DHTML 日历 | LGPL |
| RTE | http://www.kevinroth.com/rte/demo.htm | Rich Text 文本编辑 | free |
| dompdf | http://www.digitaljunkies.ca/dompdf | html 到 pdf 转f换器 | free |
BizDataObj metadata DTD 文件
<!--OpenBiz BizObj metadata DTD--> <!ELEMENT TableJoins (Join+) > |
BizView metadata DTD file.
<!--OpenBiz BizView metadata DTD--> |
BizForm metadata DTD 文件
<!--OpenBiz BizForm metadata DTD--> <!ELEMENT DisplayModes (Mode+) > |
Plugin service metadata DTD 文件
<!--OpenBiz Plugin service metadata DTD--> |
这份文件是openbiz2.0中文手册(二)
- User URL string as controller.php?view=...&form=...&rule=...&mode=...&OtherInputs...
- Use client javascript GoToView(view, rule, loadPageTarget)
| Input | Description | Sample |
| view | bizview name | shared.CalDetailView |
| form | bizform name. This form must not depend on (a subform of) another bizform | shared.FMCalDetail |
| rule | the search rule of a bizform
syntax is "form.ctrl operator value". |
FMSponsor.spr_exp>=12000
FMSponsor.spr_name=\'Midas Auto\' OR FMSponsor.spr_id=\'SPSR_2\' FMSponsor.spr_name LIKE \'S%\' |
| loadPageTarget | the window or frame target to load the page |
Smarty template engine is used in OpenBiz to render the HTML output. We provides some basic templates for render BizForm and BizView. You can create your own templates. Remember that an openbiz form must begin with a form tag <form id={$name} name={$name}>. For detail, please refer to http://smarty.php.net/docs.php
Smarty engine recognizes the subdirectories under the main template directory. So you can create a fold under demoapp/templates/ and put template files there. When you give template file name in metadata file, just give Template="subdir/view.tpl".
In BizForm xml file, you need give DataFormat as "block" and FormatStyle as table style which is given in css file.
<Mode ... TemplateFile="list.tpl" ... DataFormat="htmltable" FormatStyle="tbl"/>
In template file, {$fmttable}represents form whole html table.
Please refer to demo files FMEvent.xml and list.tpl
Since the array dataformat output to smarty template is associated array, user can easily layout controls by their names. The associated array has format as fields[control_name][label] and fields[control_name][control].
Please refer to demo files FMEvent.xml and edit.tpl
Three DataFormats decide what data is passed to templates
| DisplayMode DataFormat | Data passed to template | Controllability on template | Example |
| array | - Variable name to use in template is $fields - associated array of single record - array (control_name=>array ("label"=>label_text, "control"=>control_html)) |
Highly controllable in template | edit.tpl |
| table | - Variable name to use in template is $table - 2D array of multiple records - array (index=>array (control1_name=>value1, control2_name=>value2, ...)) array[0] is column header array[1-n] are the 1st record to nth record |
Highly controllable in template | rptlist.tpl |
| block | - Variable name to use in template is $block - HTML string |
lowly controllable in template | list.tpl |
Only basic usage of BizDataObj is listed below. Please refer to the API doc for details.
1.x BizObj is renamed as BizDataObj in 2.0, because it mainly acts as business data unit.
1.x use GetField and SetField to do get and set field values. In 2.0, no field level methods, but using GetRecord() and UpdateRecord() method to do record level operations. The idea behind is to make easier coding to retrieve query results and provide coarse-grained interfaces between 2 layers.
1.x way to query and get records
$bizobj->SetSearchRule("..."); // set search rule
$bizobj->RunSearch(-1); // run query against the database tables.
$bizobj->Home(); // reset the result record set
$hasVal = $bizobj->MoveFirst(); // move cursor to first record
while ($hasVal)
{
foreach ($fieldlist as $field)
$field_val[] = $bizobj->GetField($field);
// user logic code can be put here.
$hasVal = $bizobj->MoveNext(); // move cursor to next record
}2.0 way to query and get records - option 1
$bizobj->SetSearchRule("..."); // set search rule
$bizobj->RunSearch(-1); // run query against the database tables. query results can be cached
while ($recArray = $bizobj->GetRecord(1)) // get current record and move the cursor to the next record
{
// user logic code can be put here. recArray is an associated array whose key is "fieldname" and value is value of the field
}2.0 way to query and get records - option 2
$bizobj->FetchRecords ($searchRule, $resultSet, $numRecords); // get the whole recordset (list of recArray), query results won't be cached
// Insert Record
$recArr = $boUser->NewRecord(); // NewRecord returns an empty record array with a generate Id field
$recArr["LastName"] = "Test";
$recArr["FirstName"] = "Add";
$ok = $boUser->InsertRecord($recArr);
if (!$ok) // handle error message
print $boUser->GetErrorMessage();// Update a record
$boUser->SetSearchRule("[Id]='USER-1006'");
$boUser->RunSearch();
$recArray = $bizobj->GetRecord(0);
$recArray["FirstName"] = "Update";
$ok = $boUser->UpdateRecord($recArray);
if (!$ok) // handle error message
print $boUser->GetErrorMessage();// Delete a record
$boUser->SetSearchRule("[Id]='USER-1006'");
$boUser->RunSearch();
$recArray = $bizobj->GetRecord(0);
$ok = $boUser->DeleteRecord($recArray);
if (!$ok) // handle error message
print $boUser->GetErrorMessage();
User can configure function in BizForm metadata file to invoke appropriate action on server side. The commonly used BizForm methods are listed below. Please refer to the API doc for details.
Query and show results
Insert a new record
Update a record
Delete a record
Copy a record
Page Navigation
According the topic at http://www.boringguys.com/?p=30, there are 3 different types of data validation checks one can do:
Syntactic and semantic validation can be implemented on client side and service side. Domain validation involves query data source, it is usually done in service code that connects to database.
Openbiz does input validation using jsval library (LGPL, http://jsval.fantastic-bits.de/). To configure a validation rules for an openbiz HTMLControl, developers can use jsVal's "Inline initialization" to add validation attributes to HTMLAttr part of HTMLcontrol and FieldControl.
<Control Name="" Type="" HTMLAttr="jsval validation attributes here" ... />
Example: <BizCtr Name="email" Type="Text" HTMLAttr="regexp='JSVAL_RX_EMAIL' minlength=5..." ... />
In addition, HTMLControl has a Required (=Y|N) attribute. It is passed to pass as $fields['required'] (along with $fields['label'] and $fields['control']) to smarty template. In smarty template (edit.tpl), has code {if $item.required=="Y"} <span class='required'>*</span>{/if} to append a * to the label. Then the required control's label looks as "Email *"
Openbiz mainly support validation on BizDataObj. In BizField, Required and Validator attributes are used for such purpose. Please see the BizDataObj configuration chapter for explanation of these two attributes.
Developers can use customer class to override DataObj::ValidateInput() method or Field::Validate() method achieve their own validation rules.
BizForm has an empty ValidateForm method which may be overridden by customer classes to implment special validation logic.
OpenBiz provide many functionalities to building a complicated web application. But different application has different requirement, so you may extend OpenBiz packages to build customer applications.
Because OpenBiz packages are based on object-oriented design, you can easily build up your own object by extending these packages and inherit all useful functions provided by them.
Extended classes are automatically loaded on demand. Extended class must be included in a file with format as ClassName.php.
Use can specify class name for BizDataObj, BizField, BizView, BizForm, BizCtrl, Control and PluginService by filling the "Class" attribute of in metadata file
| Base Class | Where to specify the extend class |
| BizDataObj | <BizDataObj ... Class="" ...> |
| BizField | <BizField ... Class="" ...> |
| BizView | <BizView ... Class="" ...> |
| BizForm | <BizForm ... Class="" ...> |
| FieldControl | <BizCtrl ... Class="" ...> |
| HTMLControl | <Control ... Class="" ...> |
Example: Extend BizDataObj and BizForm
/**
* class BOUser is the BizDataObj class to implement USER logic object
*/
class BOUser extends BizDataObj
{
function BOUser($xmlFile=null) {}
function my_special_function() {} // new function
}
/**
* class FMUser is the BizForm class to implement USER UI object
*/
class FMUser extends BizForm
{
function FMUser($xmlFile=null) {}
function my_special_function() {} // new function
function Render() {} // override Render()
}
BizForm is the main server side presentation class, it has its counterpart class on client browser side. In the BizForm metadata, users can specify client side class in jsClass attribute of BizForm element. For example.
<BizForm Name="FMEvent" ... Class="BizForm" jsClass="jbForm"...>
Openbiz provides two client side classes AjaxForm and jbForm that is a subclass of AjaxForm.
AjaxForm methods:
jbForm methods:
To implement UI logic on client side, developers need to create their own client side class like jbForm and give the class name to jsClass attribute of BizForm element. If you need special logic in some methods, add these methods in the client class, which can be subclass of either AjaxForm or jbForm. These methods can be pure client code or it can this.CallFunction(...) to send the request to server.
An example:
Form metadata file is like:
| <BizForm ... Class="MyForm" jsClass="MyjbForm"...> ... <BizCtrl Name="mybutton" ...> <EventHandler Name="onclick" Event="onclick" Function="server_MyButtonClick"/> <EventHandler Name="onblur" Event="onblur" Function="js_MyButtonBlur"/> ... </BizForm> |
In server side MyForm class, server_MyButtonClick() needs to be defined.
In client side MyjbForm class, js_MyButtonBlur() needs to be defined. Of course, if server_MyButtonClick() is defined in client class, server_MyButtonClick() needs to call this.CallFunction("server_MyButtonClick", params_array) at the end of the method to send the request to server MyForm server_MyButtonClick() method. The client side code will be like:
| function MyjbForm(name) {} MyjbForm.inheritsFrom(jbForm); //set inheritance MyjbForm.prototype.js_MyButtonBlur = function (params_array) { // put client logic here ... } MyjbForm.prototype.server_MyButtonClick= function (params_array) { // put client logic here ... // send request to server side at the end this.CallFunction("server_MyButtonClick", params_array); } |
Openbiz customer can write their special logic by implement Plug-in Service. Plugin services are also metadata-driven objects. Service code is under bin/service and metadata is under /metadata/service. The plugin service metadata only gives the service name, package and implementing class. Any xml elements can be child of the root PluginService element. This is because different services may have different metadata configuration. Please refer to the Appendix to see the DTD of plugin service metadata xml file.
Openbiz core library includes services under openbiz/bin/service/ and their metadata files under openbiz/metadata/service/.
In the application, you can specify your own plugin service implementation with following methods.
Write a plug-in service
Implement the class and method in the ClassName.php
A input argument of the method are the caller's object name (a BizForm name) and the input data string (a collection of form values from client browser). It implements the user-specific business logic and returns void. See the following code snippet.
class pdfService
{
function pdfService() {}
function renderView($viewName)
{
global $g_BizSystem;
// get the view object and render the view to a html string
$viewobj = $g_BizSystem->GetObjectFactory()->GetObject($viewName);
if($viewobj) {
$viewobj->SetConsoleOutput(false);
$sHTML = $viewobj->Render();
// convert HTML to PDF
// ... customer code to do the convert
}
}
Call a plug-in service method
Openbiz uses authentication service (usrlib/authService.php) to authenticate username and password
public function AuthenticateUser ($userid, $password) is called to authenticate user.
View access control depended on the AccessControl attribute in view metadata file in Openbiz 1.x. From Openbiz RC1, openbiz implements role-based view access control in its new security architecture.
Openbiz uses profile service (usrlib/profileService.php) to get user profile that includes "role". Then match this role to access service (usrlib/accessService.php) to determine the users' accessibility to the view
public function GetProfile ($userid=null) is called to get user profile array which is an associated array with profile key and profile value pairs.
public function AllowViewAccess ($viewName, $role=null) is called to check the accessibility of a view
Openbiz uses profile service (usrlib/profileService.php) to get user profile that includes attributes. Then based on these attributes to determine browse/update/delete permission of data record. The data access permissions are controlled in BizDataObj.
User can refer to attributes by @profile:attribute in BizDataObj metadata files. Profile attributes are all from profileService. When user first login, profileService returns a profile array that is saved in session. If an attribute is found in the profile array, the attribute value is returned. If the profile array doesn't contain such attribute, profileService method GetAttribute ($userid, $attr) is called to return the attribute value. Customer must implement GetAttribute method with their own logic.
- Data browse permission. A typical access control requirement is to limit the accessibility of table record to different users. This feature can be achieved by configuring AccessRule in BizDataObj metadata file. We do the configuration with the following two scenario.
| Scenario | Configuration |
| Event can be only accessed by the owner
(personal access control) |
<BizDataObj Name="Event" ... AccessRule="[OwnerId]='@profile:ORGID'" ...>
<BizField Name="OwnerId" Column="OWNER_ID"/> |
| Event can be accessed by all invited attendees
(if the login user is one of the attendees, he can access the event) |
<BizDataObj Name="Event" ... AccessRule="[AttendeeId]='@profile:USERID'" ...>
<BizField Name="AttendeeId" Column="ATTD_ID" Join="Attendee"/> <Join Name="Attendee" Table="evts_attds" Column="EVT_ID" ColumnRef="SYSID" JoinType="LEFT JOIN"/> |
- Data update permission. UpdateCondition is to control the record update permission. UpdateCondition expects true or false. A sample is UpdateCondition = "[OrgId]=={@profile:ORGID}". {} is the evaluated as simple expression.
- Data delete permission. DeleteCondition is to control the record delete permission. DeleteCondition expects true or false. A sample is DeleteCondition = "'admin'=={@profile:ROLEID}"
Wizard is a sequence of forms (questionnaires) which guide users to complete a complicated task. An example is filling an expense report which include different types (hotel, airfare, other activities...) of expenses.
Openbiz support wizard by easy metadata configuration. Openbiz wizard has following features:
To see sample of wizards, go to Test view, click on "Wizard tests +" submenus. As you can see from the demo, wizard can be accessed with an url.
As shown in the 2nd link, developer can give the parameter on the fly to run the wizard against given record
Openbiz wizard is a regular view that contains several wizard forms. So configuring a wizard in openbiz is no harder than configuring a BizView. The difference between a wizard view and regular view is wizard view show the wizard forms one by one based on the their sequence in view metadata file, but regular view show all forms in one page. Below is an example of a wizard view metadata file.
<?xml version="1.0" standalone="no"?>
<BizView Name="EventWizardView" Description="" Package="demo" Class="BizViewWizard" Template="view.tpl">
<ControlList>
<Control Name="wizardForm1" Form="FMEventWzd1"/>
<Control Name="wizardForm2" Form="FMEventWzd2"/>
</ControlList>
<Parameters>
<Parameter Name="Evt_Id" Value="" />
</Parameters>
</BizView>
A wizard form is a regular form with class as BizFormWizard or BizFormNewWizard (or their subclasses).
This is a typical wizard form metadata file.
<?xml version="1.0" standalone="no"?>
<BizForm Name="FMNewEventWzd1" Package="demo" Class="BizFormNewWizard" jsClass="jbForm" Title="Enter event information:" SearchRule="" Description="Event BizForm" BizDataObj="BOEvent">
<DisplayModes>
<Mode Name="EDIT" TemplateFile="edit.tpl" DataFormat="array" FormatStyle="" />
</DisplayModes>
<BizCtrlList>
<BizCtrl Name="evt_id" FieldName="Id" DisplayName="Event Id" />
<BizCtrl Name="evt_name" FieldName="Name" DisplayName="Name" Type="" Width="250" />
<BizCtrl Name="evt_desc" FieldName="Description" DisplayName="Description" Type="Textarea" />
<BizCtrl Name="evt_host" FieldName="Host" DisplayName="Host" />
</BizCtrlList>
<Toolbar>
<Control Name="btn_back" Image="" Caption="< Back" Type="Button" Function="GoPrev()" />
<Control Name="btn_next" Image="" Caption="Next >" Type="Button" Function="GoNext()" />
<Control Name="btn_cancel" Image="" Caption="Cancel" Type="Button" Function="DoCancel()" PostAction="view:demo.EventView"/>
<Control Name="btn_finish" Image="" Caption="Finish" Type="Button" Function="DoFinish()" PostAction="view:demo.EventView"/>
</Toolbar>
<Navbar>
</Navbar>
</BizForm>
If application has speical logic, Openbiz suggest developers to write their own wizard form class drived from BizWizardForm. By overriding GoPrev(), GoNext(), DoCancel() and DoFinish() methods, developers can do different handling on navigation buttons events.
Openbiz wizard view play the role as a form controller where wizard form can set/get input data, cancel/finish the whole wizard process and render wizard forms. Please see the API document for details.
Upon dataobjects update/delete operations, openbiz allows triggering different alerts and action requests based on boolean results from search criteria for specific object. Briefly it is called DO Trigger which executes in a response to a change in the values stored in the database. DO trigger has two parts - trigger events and trigger actions. These information are defined in DOTrigger plugin service metadata files. At runtime when user update/delete a BizDataObj record, openbiz searches for this dataobj's trigger by looking for its trigger metadata file with name DataObjName_trigger.xml under the same directory. For example, demo/BOEvent's dataobj trigger metadata file is demo/BOEvent_trigger.xml.
<PluginService Name="BOEvent_Trigger" Description="" Package="demo" Class="service.doTriggerService" DataObjectName="BOEvent">
<DOTrigger TriggerType="UPDATE|DELETE">*
<TriggerCondition Expression="" ExtraSearchRule="" />
<TriggerActions>
<TriggerAction Action="Method_Name" Immediate="Y|N" DelayMinutes="" RepeatMinutes="">
<ActionArgument Name="" Value="" /> *
</TriggerAction>
</TriggerActions>
</DOTrigger>
</PluginService>
| Trigger conditions | Description | Sample |
| trigger type | Update or Delete record | |
| expression | any expression supported by openbiz | {[Expense]}>100. Check if current record's Expense field > 100 |
| extra search rule | search rule added on the current dataobj search rules | {[AlertFlag]}='Y'. Check if there's at least one record whose AlertFlag is 'Y' |
| Trigger action methods | Description | Parameters |
| ExecuteSQL | ExecuteSQL method executes SQL statement | Name="DBName" Value="Default" Name="SQL" Value="select * from regist where EVENT_ID='{[Id]}'" |
| ExecuteShell | ExecuteShell method executes external application | Name="Script" Value="dir" Name="Inputs" Value=" > d:\temp\out.txt" |
| SendEmail | SenEmail method sends outbound emails.
It calls emailService's sendEmail method |
Name="EmailService" Value="service.emailService" Name="Account" Value="MyPhpopenbiz" Name="TOs" Value="rockyswen@gmail.com; rockyswen@phpopenbiz.org" Name="CCs" Value="" Name="BCCs" Value="" Name="Subject" Value="alert message" Name="Body" Value="This is an alert message. \nPlease notice that the record with {[Id]} was updated." Name="Attachments" Value="" |
| AuditTrail | Trace record field change
It calls auditService Audit method |
Name="AuditService" Value="service.auditService" Name="DataObjectName" Value="{@:Name}" |
| any method in doTriggerService | The method of doTriggerService is called | Parameters needed to the method |
Due to the extensibility nature of metadata xml files, developers can create their own metadata file, which does not comply with openbiz metadata DTD, to describe the behavior of objects. Openbiz converts xml file to a php array and pass it to the class constructor to save developers' parsing work. Developers need to write their own code to extend from MetaObject class and read in the array by overriding ReadMetadata(&$xmlArr) method.
This is the good example of using customer metadata xml file. Openbiz 2.1 supports tabs UI component. The metadata file (demo/tabs.xml) is like
<?xml version="1.0" standalone="no"?>
<BizForm Name="Tabs" Package="demo" Class="HTMLTabs">
<TabViews>
<View Name="demo.AttendeeView" URL="" Caption="Attendees"/>
<View Name="demo.EventView" URL="" Caption="Events"/>
</TabViews>
</BizForm>
The class code is under openbiz/bin/HTMLTabs.php. Its css file is in openbiz.css.
Developer can draw more UI widgets like tree, menu using the same approach.
Openbiz 2.1 supports menu UI component. The metadata file of a menu (i.e. demo/Menus.xml) is like
<?xml version="1.0" standalone="no"?>
<Menu Name="Menus" Package="demo" Class="HTMLMenus">
<MenuItem URL="" Caption="" Target=""> *
<MenuItem URL="" Caption="" Target=""/> *
The class code is under openbiz/bin/HTMLMenus.php. Its css file is /css/menu.css
The menu provided in the demo application can be seen in "Test" view. This menu is a horizontal dropdown menu. It is a pure css menu. The idea is copied from http://solardreamstudios.com/learn/css/cssmenus. The output html (<ul><li>...) has same format of the output of well-known DynarchMenu http://www.dynarch.com/products/dhtml-menu/. So integration with DynarchMenu is an easy job. Of course, developers are free to modify the HTMLMenus class to work with other menu libraries. Same principle will apply to other customer UI components.
Openbiz 2.1 supports tree UI component. The metadata file of a tree (i.e. demo/Tree.xml) is like
<?xml version="1.0" standalone="no"?>
<Tree Name="Tree" Package="demo" Class="HTMLTree">
<Node URL="" Caption="" Target=""> *
<Node URL="" Caption="" Target=""/> *
The class code is under openbiz/bin/HTMLTree.php. Its css file is in openbiz.css
The tree provided in the demo application can be seen in "Test" view. The technique of drawing tree is same as the tree of Eclipse help system http://help.eclipse.org/help30/index.jsp. Again, developers are free to modify the HTMLTree class to work with other tree libraries.
The openbiz look and feel is controlled by stylesheet css files. The main css file is /css/openbiz.css
In case of using Format="block" in the BizForm's displayMode, users can modify the following section in css/openbiz.css file.
/* -------- table style -------- */
.tbl {...}
.tbl .head {...}
.tbl .rowodd {...}
.tbl .roweven {...}
.tbl .rowsel {...}
.tbl .cell {...}
In order to give user specific tab styles, users can modify the following section in css/openbiz.css file.
/* -------- tabs style -------- */
.tabmenu {...}
.tabmenu li {...}
.tabmenu a, a.active {...}
.tabmenu a.active {...}
.tabmenu a:hover {...}
.tabmenu a:visited {...}
.tabmenu a.active:hover {...}
In order to give user specific tab styles, users can modify the following section in css/menu.css file.
In order to give user specific tree styles, users can modify the following section in css/openbiz.css file.
/* ----- tree style ----- */
UL.expanded {...}
UL.collapsed {...}
LI.tree {...}
In order to give user specific RTE styles, users can modify the following section in pages/rte/rte.css file.
The DHTML calendar is well documented at http://www.dynarch.com/demos/jscalendar/doc/html/reference.html. The javascript file is under demoapp/js/jscalendar.
- Logging. BizSystem::log() method can be called to log 4 priority levels LOG_EMERG, LOG_ERR, LOG_WARNING and LOG_DEBUG. Also a subject can be specified to give log messages different categories. The error is logged under /log/log_error.html, open it and you may find out what's wrong
- Debugging. Other than the DEBUG flag in 1.1.x is still valid, developers can turn on other 2 debug flags.
1) Open the sysheader.inc under /bin, turn on debug log by changing define("DEBUG", 1); Then you'll see some debug information in /log/log_debug.html. This debug file records mainly the database calls and other operations
2) Turn on SQL debug flag. Uncomment //$this->m_DbConnection[$rDBName]->debug = true; in BizSystem::GetDBConnection().
3) Turn on RPC debug flag, each RPC response is printed in a separate window. Set var RPC_DEBUG = true; in clientUtil.js.
Openbiz Eclipse插件协助openbiz 用户在Eclipse环境里开发openbiz 应用。
首先删除旧的Openbiz Eclipse插件。下载openbiz_eclipse_0.9.x.zip 从openbiz sourceforge 网站。同其它Eclipse plugins 的安装一样, 将文件unzip 到eclipse目录。然后再开始Eclipse。Openbiz 插件工作在Eclipse3.x 之上。
以确信openbiz 插件可以连接到必需为openbiz 开发所需要的数据库, 请编辑在ECLIPSE_ROOT/plugins/org.openbiz.metadata_0.9.x/config 之下的config.xml 文件。在文件立有一个被预设的数据库元素, 它将使用connect/j JDBC driver 连接本机的MySql 数据库。请将其改成正确jdbc driver 和数据库url。
<Database DriverFile="D:\java\eclipse\plugins\org.openbiz.metadata_0.9.x\lib\mysql-connector-java-3.1.10-bin.jar" DriverClass="com.mysql.jdbc.Driver" ConnectURL="jdbc:mysql://localhost:3306/demo" Schema="" User="root" Password="root"/>
配置数据库元素, 以下属性必须正确地被设定。
在 Eclipse 的帮助下, openbiz 的目录可被 eclipse 项目(project)管理. 用户可创建一个指到openbiz 应用目录(或 openbiz/metadata) 的项目. Openbiz project 树会出现在 eclipse Navigator view. 见下图

从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizDataObj metadata file.
然后在后面的页上做以下任务。
在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。编辑看起来象eclipse Plug-in Menifest 编辑。概要页显示根metadata 对象, 其他页展示xml 树第二层次xml 元素的信息。见下图

plugin提供三种方式来编辑metadata 文件, 见下图

像创建 BizDataObj 一样, 从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择 New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizForm metadata file.
然后在后面的页上做以下任务。
在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。
Screenshot: 用鼠标右键单击控制, 从菜单项目增加EventHanlder

Screenshot: 编辑控制的event handler

像创建 BizDataObj 一样, 从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizView metadata file.
然后键入metadata 文件名, 点击结束按钮
在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。
BizView 可以用以下url 格式:
openbiz_root_path/bin/controller.php?view=package.viewname
例如, http://localhost/demoapp/bin/controller.php?view=shared.SignupView