Openbiz 2.x 中文手册

Openbiz 2.x 手册中文版, 中文Powerpoint 教程, Openbiz 中文论坛

Openbiz 宣传册

当你期望用最好的用户界面开发, 在一个出类拔萃的应用程序框架之上, 并且最大限度地降低开发和技术支持成本… 你会发现所有这一切都在OPENBIZ - 使应用开发不同于编程!


系统简介

Openbiz提供了一个PHP 应用程序框架。它可以帮助专业软件开发人员和技术咨询家来构建网络上企业级应用。由于企业级应用的高复杂性,系统开发通常会包括巨大投资和冗长的时间去进行工程计划,系统设计,原型设计,组件编码,功能测试,产品部署以及维护。

Openbiz框架的目标是节省复杂应用的开发投入和缩短开发时间。借助于Openbiz的帮助,应用程序的开发将建立于一个拥有完全互联网(Web)层面的,以Metadata驱动为核心的,并且有Eclipse插件作为图形化编写工具的平台。

技术优势

Metadata驱动

Openbiz是一个Metadata驱动的框架。这意味着Openbiz对象(Objects)的创立是基于Metadata的文字描述。构建一个应用意味着设计和编写XML格式的Metadata文件。因此,基于Openbiz的应用软件包是完全可客户化的,而且是极其容易开发和维护的。

完全互联网(Web)层面

Openbiz被设计成一个多层面的结构。以下的图表说明了这一点。它涵盖了完全互联网(Web)层面,从网页流览器作为客户机到服务器这边的数据整合层面。使用Openbiz,软件开发者可以节省花在与其他软件库接口的工作。

MVC(模型-视图-控制器)模式

Openbiz框架内部继承了MVC(模型-视图-控制器)的设计模式。这使得基于Openbiz的应用非常容易来开发和管理,因为表述层的程序与商业数据和逻辑清楚地分离开来。

ORM(对象关系映射)

Openbiz的内核实现了对象关系映射功能。Openbiz以BizDataObj对象来表述数据库表格和它们之间的逻辑关系。Openbiz支持的映射包括一对多,多对一,一对一和多对多的对象逻辑关系,并且支持与标准结构化查询语言(SQL)相似的查询语言。

安全模型

安全性是现今商业应用环境中必不可少的组成部分。Openbiz的安全模型可用来创建用户身份验证,基于角色的视图许可控制以及基于属性的数据许可控制。

与Eclipse集成的编辑工具

Openbiz的编辑工具与当前最流行的Eclipse开发环境集成在一起。Openbiz的编辑工具是一个Eclipse的插件。它提供几种不同的向导来帮助开发人员创建新的Metadata文件,并提供图形用户界面来编辑这些文件。与此同时开发人员可以利用Eclipse的其他强大功能。

提升效率

  • Openbiz框架的Metadata特性保证了开发可以迅速因需求而变化,也使得应用更容易升级和维护。
  • Openbiz提供了一个强大的武器给软件咨询公司,开发人员,甚至管理者去快速满足他们商业客户的需求。
  • 由于Openbiz的授权许可证是完全免费的(BSD),而且允许被发布于商业软件中,这也是选择Openbiz的另一个理由。

投资回报

  • 低成本。由于Openbiz的免费许可证和短时的开发过程,你将花极少的费用在购买软件和雇佣咨询公司上,而且得到更好的产品。
  • 迅速部署。基于Openbiz的应用是完全可重配置的,这样它能够迅速因需求而变化。你将很快看到回报。
  • 低维护费用。管理Openbiz的Metadata比起管理程序要简单得多。

用户经验

  • “我们正在想办法来代替公司以有的过时的用Visual Basic编写的程序。Openbiz是我们发现的最好的开发框架。”-Andrew, 美国
  • “我们花了两个月来研究不同的应用框架,Openbiz是唯一的系统,它能创建Web应用而不需要了解PHP编程。”-Nik, 保加利亚
  • “我高兴地给出A+,因为我对Openbiz的问题得到了迅速而且完美的解答。Openbiz框架的确厉害!”-Douglas, 法国

Openbiz 2.2 中文手册

Openbiz 2.2 概要

Openbiz 2.2 安装

  • 下载和安装 
  • 演示应用

Openbiz 2.2 新特点

  • 建造在Zend 框架上
  • 用APC 提高性能
  • Openbiz 对象的改进
    • BizDataObj 改进
    • BizForm 改进
    • BizView 改进
  • 与BIRT 报表集成
  • 支持tabs and sub tabs
  • 新的界面
  • 树状结构的解决方案 - BizFormTree

附录- metadata DTD 文件


这个文件介绍Openbiz 2.2 在版本2.1之上的新改进的特点 。Openbiz 2.1 指南仍然可在版本2.2使用 。

Openbiz 2.2安装

下载和安装Openbiz 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);

Openbiz 2.2 演示应用

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

Openbiz 2.2 新特点

建造在Zend 框架之上

  • 用Zend_Db (基于PDO) 替换ADODB 数据库抽象库 。好处包括更高的性能和更低的 memory footprint。
  • Zend 框架提供许多有用的功能
  • Zend 框架是正式官方的php 框架, 但这是仍然一个底层的工具库。Openbiz 应用框架着重于应用层。

用APC 提高性能

与BIRT 报表集成

产生报表是商业应用一个非常重要特点。通过利用 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 显示报告的步骤:

  1. 确定Openbiz 代码可能访问BIRT viewer 服务器目录。Openbiz reportService 将生成一个BIRT 报表设计并将其复制到BIRT viewer 报表目录。
  2. 用Eclipse设计师创造一个BIRT 报告。使用csv 文件作为它的数据源和数据集。假设现在我们有一个BIRT 报告设计文件叫做abc.rptdesign 。
  3. 以smarty 模板句法转换上述rptdesign 文件成模板。例如, 替换resultset 结构用{foreach} 。abc.rptdesign 成为abc.rptdesign.tpl 。下表是转换设计成模板的例子。
    resultset in .rptdesign resultset in template
    <list-property name="resultSet">
    <structure>
    <property name="position">1</property>
    <property name="name">AttendeeId</property>
    <property name="nativeName">AttendeeId</property>
    <property name="dataType">string</property>
    <property name="nativeDataType">12</property>
    </structure>
    <structure>
    <property name="position">2</property>
    <property name="name">Income</property>
    <property name="nativeName">Income</property>
    <property name="dataType">string</property>
    <property name="nativeDataType">12</property>
    </structure>
    </list-property>
    <list-property name="resultSet">
    {foreach item=fld from=$rpt_fields}<structure>
    <property name="name">{$fld.name}</property>
    <property name="nativeName">{$fld.name}</property>
    <property name="dataType">{$fld.type}</property>
    <property name="nativeDataType">12</property>
    </structure>
    {/foreach}
    </list-property>
  4. 复制模板文件到Openbiz 应用的template 目录之下。Openbiz demoapp 有缺省BIRT 设计模板文件"dataobj.rptdesign.tpl" 在它的模板目录之下。
  5. 创造reportService metadata, 它指定TargetReportPath 、ReportTemplate 和BIRTViewer url。您能在openbiz/metadata/service/reportService.xml发现reportService metadata 的例子
  6. 在BizForm增加一个按钮来调用reportService render 方法。Openbiz demoapp Attendee BizForm (在Attendee tab) 有一个报表按钮。相似的按钮可能被创造在任一BizForm 界面 。
  7. 当用户点击报表按钮, 他或她将得到显示报表的一些选择。

支持 tabs and sub tabs

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"?>
<Tabs Name="Tabs" Package="demo" Class="HTMLTabs" TemplateFile="tabs.tpl">
<TabViews>
<View Name="home" URL="./home.php" Caption="Home"/>
<View Name="event" URL="" View="demo.EventView" ViewSet="EventSet" Caption="Events" Icon=""/>
<View Name="regist" URL="" View="demo.RegistView" Caption="Registration" Icon=""/>
<View Name="attendee" URL="" View="demo.AttendeeView" Caption="Attendees" Icon=""/>
<View Name="reports" URL="./report.php" Caption="Reports" Icon=""/>
<View Name="test" URL="" View="demo.FieldDepTestView" Caption="Test 2.1 Features" Icon=""/>
</TabViews>
</Tabs>
demo/EventTabs.xml
<?xml version="1.0" standalone="no"?>
<Tabs Name="EventTabs" Package="demo" Class="HTMLTabs" TemplateFile="subtabs.tpl">
<TabViews>
<View Name="EventAttendee" URL="" View="demo.EventView" Target="" Caption="Attendees" Icon=""/>
<View Name="EventRegist" URL="" View="demo.EventRegistView" Target="" Caption="Registration" Icon=""/>
</TabViews>
</Tabs>

有一样的ViewSet = "EventSet " 的对应的视图(view)

demo/EventView.xml demo/EventRegistView.xml
<?xml version="1.0" standalone="no"?>
<BizView Name="EventView" ViewSet="EventSet"
Description="Event BizView" Package="demo"
Class="BizView" Template="view.tpl">
<ControlList>
<Control Name="_tabs" Form="Tabs"/>
<Control Name="fm_event" Form="FMEvent" SubCtrls="FMAttendeeChild"/>
<Control Name="_subtabs" Form="EventTabs"/>
<Control Name="fm_attd" Form="FMAttendeeChild"/>
</ControlList>
</BizView>
<?xml version="1.0" standalone="no"?>
<BizView Name="EventRegistView" ViewSet="EventSet"
Description="Event BizView" Package="demo"
Class="BizView" Template="view.tpl">
<ControlList>
<Control Name="_tabs" Form="Tabs"/>
<Control Name="fm_event" Form="FMEvent" SubCtrls="FMRegistChild"/>
<Control Name="_subtabs" Form="EventTabs"/>
<Control Name="fm_regist" Form="FMRegistChild" />
</ControlList>
</BizView>

由于EventView 和EvenrRegistView 分享同样ViewSet, 在他们之间互换将保留对FMEvent 和它的BOEvent 同样对象的上下文。例如, 在EventView 用户在上面的form 查询"*Tennis*" , 当他点击Registration sub tab, 换到EventRegistView, 同样的查询结果被保留在新视图。 

新的界面

以优秀品质设计企业网应用通常需要web 设计师。Openbiz 2.2 demoapp 带来新的界面样式:

  • Tabs 和subtabs
  • BizForm 标题bar
  • Table column hearder 和 selected row
  • 3D 样式按钮

当然开发商可以改变在demoapp/css 之下德css 文件来应用他们自己的样式。

树状结构的解决方案 - BizFormTree

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. 这个类提供两个新的方法

  • ListChildren($id) - 列出某一纪录的所有子记录
  • ListSiblings($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 的一个例子.


附录- metadata DTD 文件

蓝色文字表示Openbiz 2.2 中新的元素

BizDataObj metadata DTD 文件

<!--OpenBiz BizObj metadata DTD-->

<!ELEMENT BizObj (BizFieldList, TableJoins, ObjRefernces, Parameters) >
<!ATTLIST BizObj Name CDATA #REQUIRED >
<!ATTLIST BizObj Description CDATA #REQUIRED >
<!ATTLIST BizObj Package CDATA #IMPLIED >
<!ATTLIST BizObj Class CDATA #REQUIRED >
<!ATTLIST BizObj InheritFrom CDATA #IMPLIED >
<!ATTLIST BizObj DBName CDATA #IMPLIED >
<!ATTLIST BizObj Table CDATA #REQUIRED >
<!ATTLIST BizObj SearchRule CDATA #IMPLIED >
<!ATTLIST BizObj SortRule CDATA #IMPLIED >
<!ATTLIST BizObj OtherSQLRule CDATA #IMPLIED >
<!ATTLIST BizObj AccessRule CDATA #IMPLIED >
<!ATTLIST BizObj UpdateCondition CDATA #IMPLIED >
<!ATTLIST BizObj DeleteCondition CDATA #IMPLIED >

<!ATTLIST BizObj Stateless CDATA #IMPLIED >

<!ELEMENT BizFieldList (BizField+) >
<!ELEMENT BizField EMPTY >
<!ATTLIST BizField Name CDATA #REQUIRED >
<!ATTLIST BizField Class CDATA #IMPLIED >
<!ATTLIST BizField Join CDATA #IMPLIED >
<!ATTLIST BizField Column CDATA #REQUIRED >
<!ATTLIST BizField SQLExpr CDATA #IMPLIED >
<!ATTLIST BizField Type CDATA #IMPLIED >
<!ATTLIST BizField Format CDATA #IMPLIED >
<!ATTLIST BizField Required CDATA #IMPLIED >
<!ATTLIST BizField Validator CDATA #IMPLIED >
<!ATTLIST BizField DefaulValue CDATA #IMPLIED >
<!ATTLIST BizField Value CDATA #IMPLIED >
<!ATTLIST BizField OnAudit CDATA #IMPLIED >
<!ELEMENT TableJoins (Join+) >
<!ELEMENT Join EMPTY >
<!ATTLIST Join Name CDATA #REQUIRED >
<!ATTLIST Join Table CDATA #REQUIRED >
<!ATTLIST Join Column CDATA #REQUIRED >
<!ATTLIST Join JoinRef CDATA #IMPLIED >
<!ATTLIST Join ColumnRef CDATA #REQUIRED >
<!ATTLIST Join JoinType CDATA #REQUIRED >

<!ELEMENT ObjReferences (Object+) >
<!ELEMENT Object EMPTY >
<!ATTLIST Object Name CDATA #REQUIRED >
<!ATTLIST Object Description CDATA #IMPLIED >
<!ATTLIST Object Relationship CDATA #REQUIRED >
<!ATTLIST Object Table CDATA #REQUIRED >
<!ATTLIST Object Column CDATA #REQUIRED >
<!ATTLIST Object FieldRef CDATA #REQUIRED >
<!ATTLIST Object CascadeDelete CDATA #IMPLIED >
<!ATTLIST Object XTable CDATA #IMPLIED >
<!ATTLIST Object XColumn1 CDATA #IMPLIED >
<!ATTLIST Object XColumn2 CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

BizView metadata DTD 文件

<!--OpenBiz BizView metadata DTD-->

<!ELEMENT BizView (ControlList, Parameters) >
<!ATTLIST BizView Name CDATA #REQUIRED >
<!ATTLIST BizView Description CDATA #REQUIRED >
<!ATTLIST BizView ViewSet CDATA #IMPLIED >
<!ATTLIST BizView Package CDATA #IMPLIED >
<!ATTLIST BizView Class CDATA #IMPLIED >
<!ATTLIST BizView Template CDATA #IMPLIED >

<!ELEMENT ControlList (Control+) >
<!ELEMENT Control EMPTY >
<!ATTLIST Control Name CDATA #REQUIRED >
<!ATTLIST Control Form CDATA #REQUIRED >
<!ATTLIST Control SubCtrls CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

BizForm metadata DTD 文件

<!--OpenBiz BizForm metadata DTD-->

<!ELEMENT BizForm (BizCtrlList, DisplayModes, Toolbar, Navbar, Parameters) >
<!ATTLIST BizForm Name CDATA #REQUIRED >
<!ATTLIST BizForm Description CDATA #REQUIRED >
<!ATTLIST BizForm Package CDATA #IMPLIED >
<!ATTLIST BizForm Class CDATA #REQUIRED >
<!ATTLIST BizForm InheritFrom CDATA #IMPLIED >
<!ATTLIST BizForm jsClass CDATA #REQUIRED >
<!ATTLIST BizForm Title CDATA #REQUIRED >
<!ATTLIST BizForm BizDataObj CDATA #REQUIRED >
<!ATTLIST BizForm PageSize CDATA #REQUIRED >
<!ATTLIST BizForm SearchRule CDATA #IMPLIED >
<!ATTLIST BizFomr Stateless CDATA #IMPLIED >

<!ELEMENT BizCtrlList (BizCtrl+) >
<!ELEMENT BizCtrl (EventHandler+) >
<!ATTLIST BizCtrl Name CDATA #REQUIRED >
<!ATTLIST BizCtrl Class CDATA #IMPLIED >
<!ATTLIST BizCtrl FieldName CDATA #IMPLIED >
<!ATTLIST BizCtrl DisplayName CDATA #IMPLIED >
<!ATTLIST BizCtrl Type CDATA #IMPLIED >
<!ATTLIST BizCtrl Width CDATA #IMPLIED >
<!ATTLIST BizCtrl Height CDATA #IMPLIED >
<!ATTLIST BizCtrl HTMLAttr CDATA #IMPLIED >
<!ATTLIST BizCtrl Link CDATA #IMPLIED >
<!ATTLIST BizCtrl Image CDATA #IMPLIED >
<!ATTLIST BizCtrl Hidden CDATA #IMPLIED >
<!ATTLIST BizCtrl Enabled CDATA #IMPLIED >

<!ATTLIST BizCtrl Sortable (Y|N) "" >
<!ATTLIST BizCtrl Order CDATA #IMPLIED >
<!ATTLIST BizCtrl Style CDATA #IMPLIED >
<!ATTLIST BizCtrl ValuePicker CDATA #IMPLIED >
<!ATTLIST BizCtrl PickerMap CDATA #IMPLIED >
<!ATTLIST BizCtrl DefaultValue CDATA #IMPLIED >
<!ATTLIST BizCtrl SelectFrom CDATA #IMPLIED >
<!ATTLIST BizCtrl DrillDownLink CDATA #IMPLIED >
<!ATTLIST BizCtrl DisplayMode CDATA #IMPLIED >

<!ELEMENT Toolbar (Control+) >
<!ELEMENT Navbar (Control+) >
<!ELEMENT Control (EventHandler+) >
<!ATTLIST Control Name CDATA #REQUIRED >
<!ATTLIST Control Class CDATA #IMPLIED >
<!ATTLIST Control Image CDATA #IMPLIED >
<!ATTLIST Control Caption CDATA #IMPLIED >
<!ATTLIST Control Type CDATA #IMPLIED >
<!ATTLIST Control Width CDATA #IMPLIED >
<!ATTLIST Control Height CDATA #IMPLIED >
<!ATTLIST Control HTMLAttr CDATA #IMPLIED >
<!ATTLIST Control Style CDATA #IMPLIED >
<!ATTLIST Control Hidden CDATA #IMPLIED >
<!ATTLIST Control Enabled CDATA #IMPLIED >
<!ATTLIST Control SelectFrom CDATA #IMPLIED >

<!ATTLIST Control DisplayMode CDATA #IMPLIED >

<!ELEMENT EventHandler EMPTY >
<!ATTLIST EventHandler Name CDATA #REQUIRED >
<!ATTLIST EventHandler Event CDATA #REQUIRED >
<!ATTLIST EventHandler Function CDATA #REQUIRED >
<!ATTLIST EventHandler FunctionType CDATA #IMPLIED >
<!ATTLIST EventHandler ShortcutKey CDATA #IMPLIED >
<!ATTLIST EventHandler PostAction CDATA #IMPLIED >
<!ELEMENT DisplayModes (Mode+) >
<!ELEMENT Mode EMPTY >
<!ATTLIST Mode Name CDATA #REQUIRED >
<!ATTLIST Mode TemplateFile CDATA #REQUIRED >
<!ATTLIST Mode DataFormat CDATA #REQUIRED >
<!ATTLIST Mode FormatStyle CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

Plugin service metadata DTD 文件

<!--OpenBiz Plugin service metadata DTD-->

<!ELEMENT PluginService ANY >
<!ATTLIST PluginService Name CDATA #REQUIRED >
<!ATTLIST PluginService Description CDATA #IMPLIED >
<!ATTLIST PluginService Package CDATA #REQUIRED >
<!ATTLIST PluginService Class CDATA #REQUIRED >

Openbiz 2.0 中文手册(一)

这份文件是openbiz2.0手册. Openbiz1.x的手册在manual11.html

其他链接:openbizeclipse插件设计师手册, openbiz最佳做法

Openbiz 2.0概况

Openbiz 安装

构建openbiz应用

Openbiz 配置指南

  • 层次管理Metadata
  • 使用对象数据继承
  • 简单的表达语言
    • 使用表达式
    • 字符
    • 操作符
    • 变量
    • 函数
    • 实例
  • 配置Bizdataobj
    • 映射Bizdataobj到数据表格
    • Bizdataobj的查询语言
    • Bizfields的数据类型和格式
    • 数据验证
  • 对象关系(O/R)的映射
    • 映射一个表格到一个Bizdataobj
    • 主键(ID)的生成
    • 复合主键的支持
    • 映射多个表格到一个Bizdataobj
    • BizDataObjs中多对一的关系
    • BizDataObjs中一对多的关系
    • BizDataObjs中多对多的关系
  • 配置BizView 和 BizForm
    • BizView - the HTML 网页容器
    • BizForm的基本布局:数据,工具栏及导航栏
    • 映射Bizdataobj到Bizform
    • 以各种不同类型的html元素来表现数据
    • BizForm的事件处理
    • BizForm键盘处理功能
    • BizForm中html元素的互相依赖
    • 配置drilldown连接到另一视图
    • 从组合或列表选择Field数据
    • 控制页面导航
    • 从BizForm导入和导出数据
    • 从BizForm上传文件

Openbiz 开发指南 (另文档)

附录一:第三方库

附录二:Metadata的文档类型定义DTD


Openbiz 2.0概况

Openbiz 2.0是一个metadata驱动的框架. 所有openbiz对象都有自己的metadata文档. Openbiz2.0建筑架构遵循模型-视图-控制器(MVC)的设计模式,它也实现了对象/关系映射.

Openbiz 2.0 架构

Metadata驱动框架

Openbiz的目标是使设计,开发和维护应用软件容易. Openbiz是xml数据驱动框架,即openbiz对象建基于描述他们的数据档案. 建立一个应用意味着设计和开发数metadata文档. 由于自我阐释性标示语言, 应用易于维护. 与此同时由于XML的可扩展性, openbiz是一个可扩展的框架.

下面的图表显示了基于metadata 对象的openbiz框架. 这些对象涵盖大部分功能需求的Web应用开发.

Openbiz对MVC的实施

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对象
其他四个.... 不适用

Openbiz实现持久对象和ORM

类似流行的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执行插件服务
用户认证 Openbiz利用认证服务(bin/service/authservice.php)认证的用户名和密码
 基于角色的视图出入管制 Openbiz用Profile服务(bin/service/profileservice.php)取得用户信息, 其中包括"角色".
然后用access服务(bin/service/accessservice.php)去查询该角色, 以确定用户的视图权限
基于属性数据存取控制 Openbiz用Profile服务(bin/service/profileservice.php),以取得用户的概况,包括属性.
然后,基于这些属性,以确定对数据记录浏览/更新/删除的许可. 数据访问权限控制在Bizdataobj.

Openbiz 2.0 的结构组织

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包内.

类图的多层结构

序列图的一个典型AJAX的调用

Openbiz客户端浏览器与服务器通过AJAX调用.


安装Openbiz

运行环境

Openbiz(2.0或更新版本)是基于php5脚本. 我们推荐平台

  • Apache HTTP Server 1.3.x or 2.x + PHP 5.x
  • Internet Information Server (IIS) 5.x + PHP 5.x

安装目录是openbiz,或者你可以配置apache使用别名.

支持浏览器 - IE5.x (或更新版本), Netscape 7.x and Mozillar/FireFox 1.x (或更新版本)

安装openbiz

下载zip文件并解压缩到一个目录下 (under web root).

请翻阅openbiz/bin目录下的sysheader.inc, 和demoapp/bin下的 app.inc.

  • Openbiz 核心路径 " OPENBIZ_HOME " 可被设置于 syshearder.inc 和 app.inc文件中. app.inc中的值先于sysheader.inc中的值.
  • sysheader.inc定义路径第三方php软件包包括 Smarty " SMARTY_DIR ", 和 Adodb " ADODB_DIR " 等等.
  • 应用 home 路径" APP_HOME ", metadata 文件路径 " META_PATH ", 日志文件路径 " LOG_PATH ", session 文件路径 " SESSION_PATH " 和 smarty 模板文件路径 " SMARTY_TPL_PATH " 在app.inc中指明.
  • " DEBUG " 显示是否打印调试信息
  • " CHECKUSER " 检查用户是否登录
  • " TIMEOUT " 是会话超时秒

源代码树结构:

从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

Upgrade guide升级指南

请参阅 http://phpopenbiz.org/document/manual.html#upgrade 

通过SVN获取最新的源代码

请参阅 http://phpopenbiz.org/document/manual.html#svn


构建Openbiz应用

为你的应用提出具体要求

OpenBiz是一个完美的工具来帮助你轻松和全面地开发复杂web应用. 基于其3层结构, 你的应用将有一个很清晰的逻辑模式. 它顾及到了面向数据的应用的基本和先进功能. 为了分辨openbiz是否可以帮助建立你的应用程序, 你需要问这些问题:

  • 你的应用是web基于的应用程序或可转换成基于web的应用?
  • 你的应用是否需要用数据库操纵不同类型的数据?

如果答案是的话, Openbiz就是正确的开发你的应用得的框架,!

计划你的web应用

当你安装Openbiz软件包时, 你会发现在zip文件有两个主要目录"openbiz"和"demoapp". "openbiz"目录包含了核心openbiz程序和metadata.  "demo"目录包含源演示应用(事件管理和日历演示).

上述结构不同于Openbiz RC2.0之前的版本, 在那里你会看到演示应用在openbiz目录里. 为什么openbiz进行了这一转变?

  • 它给开发人员带来了一个清晰的逻辑结构 - openbiz核心库和应用程序代码在不同的目录.
  • Openbiz核心库比openbiz应用更便携式, 它可以被多种应用分享.
  • 如果openbiz核心更新版本, 应用很容易的升级.

在你的目录开发web应用

自己的开发项目 目录
你的源代码 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核心. 你需要做一些额外的步骤, 建立了自己的应用程序目录. 我们建议下列步骤.

  1. 拷贝demoapp目录,并命名为你的应用的名字, 比如说"testapp"
  2. 打开 testapp/bin/app.inc, 恰当地改变常量. 如果你可以接受默认值, 不需要改变.
  3. 打开 testapp/bin/login.php, 改变 $application_homepage 到用户登录后显示给用户的首页.

在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 和代码一个明确结构.

创建数据库模式

为你的业务数据与关系数据库表建模是你的整个开发的必需的基础建设.

创造一个新的数据库

  • 指定新的数据库为metadata/config.xml的默认数据库
  • 创造"ob_users"表中存储用户名和密码. Since 2.0, openbiz counts on authentication service to authentiate user and password, so the user id and password can be stored in the storage that is queried by the authentication service.自2.0openbiz用认证服务类验证用户名和密码, 所以用户名和密码,可以储存在认证服务查询的数据库里. 
  • 创造"ob_sysids"表, 其中sysid栏为各表的ID栏
  • 每个表必须有一个ID栏, 并在ob_sysids表加上一条纪录(TABLE=你的表的名字, PREFIX=ID的前缀, IDBODY=起始整数)

Use existing database使用现有数据库

  • 指定新的数据库为metadata/config.xml的默认数据库
  • 创造"ob_users"表或重用现有含有用户名和密码栏的表. Ensure that authentication service queries the user id and password on the right table (or source).确保认证服务从正确的表(或来源)查询用户名和密码.
  • 设定IdGeneration 属性为现有ID生成算法. 例如, 如果你的oracle数据库的使用顺序来创造 PK column (主键栏), IdGeneration应为"Sequence:seqname". 细节请参阅本主键栏(ID)生成的章节.

用Openbiz来进行系统设计

用Openbiz的强大功能来进行系统设计. 你的设计将有

  • 明确三层结构栈
  • XML metadata驱动应用
  • MVC (模型-视图-控制器)设计模式
  • 一套丰富的库
  • 常见的应用功能

建立新的应用

业务需求 -> 界面设计+数据建模+对象设计

用户界面:页面, 表单, 人机互动

数据模型:数据库结构设计

对象设计:

  • 界面对象 - Bizview, Bizform
  • 数据对象 - Bizdataobj与对象/关系映射
  • 功能对象-插件服务

转换现有的应用

将现有的界面转换为bizviews, bizforms

将现有的数据库表映射到Bizdataobjs

将现有的业务功能变为插件服务

样本实例 - 日历

请参阅 http://phpopenbiz.org/document/manual.html#bld_sample 


Openbiz配置指南

开发商能选择用XML编辑器编辑metadata文件。Openbiz Eclipse插间被推荐为设计和配置工具。参见Openbiz Eclipse插入设计师指南

由包裹组织metadata

在复杂的应用, 用户也许需要建立许多对象, 因此他们有很长的metadata文件名单。如果他们将这些文件放在一个metadata目录之下, 处理metadata文件是一件痛苦的事。从openbiz 1.1, metadata文件可能由包裹名字组织。记住, metadata包裹是不同的以是代码单位的(BizObj, BizView...)包裹。Metadata包裹是一个命名系统, 不同的包裹地对映于\不同的目录。它是象被使用在Java中的包裹概念。

PackageX.PackageY.metaA.xml 指在META_PATH/PackageA/PackageB目录之下的metaA.xmlMETA_PATH是metadata根目录。这个宏变量被定义在sysheader.inc 和app.inc 。

怎么配置在metadata文件的包裹?

我们解释它以演示例子。在您unzip源码之后, 找到在metadata 目录之下演示目录。用文本编辑程序打开FMRegist.xml 文件。您将看见Package="demo" 属性在BizForm 元素。这个属性将说任一类型缺省包裹openbiz 对象是在"demo" 包裹之下。这里openbiz 对象提到以下对象类型。

目标类型

提到作为属性在metadata文件

BizObj

BizForm[BizObj ]
BizObj->BizFieldList->BizField[SelectBizObj ]

BizForm

BizView->ControlList->Control[Form ]
BizView->ControlList->Control[SubCtrl ]
BizForm->BizCtrlList->BizCtrl[SelectFrom ]

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 设法找出对象同样应用和然后核心应用。如果对象不被发现, 它报告错误。

使用对象metadata继承

如果你有一个非常复杂的应用,你要重用现有对象,以不同的地方,但是你要表现的对象在不同的情况下回有不同,. 继承对象将解决以上问题. 由于openbiz框架的对象映射到metadata数据文件, 继承对象就成为数据文件继承.

怎么指定在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
Object DisplayModes: Mode
Object Toolbar: Control
Object Navbar: Control

对象属性: Name, Package, Class, InheritFrom

简单表达式语言

为了增加metadata 配置的灵活性, Openbiz 在metadata 文件接受简单表达式语言。如果声明有 {expr} 样式, expr 将被评估作为简单的表示。 基本上, 简单表达式是返回值的一个PHP 语句。如果用户需要的复杂逻辑无法被一个简单表达式表示, 他们可将特别代码写在用户定义的类里。

使用表达式

简单表达式将支持metadata 属性动态值捆绑。在metadata 文件中用户能在以下地方使用简单表示。

  • BizDataObj
    SearchRule, SortRule, OtherSQLRule, AccessRule, UpdateCondition, DeleteCondition 。这些属性是询问BizDataObj 元素相关的属性. [ field_name ] 是询问语言的语法, 它将由表格的column 名字替换。请参见 在BizDataObj查询语言 为细节。
  • BizDataObj.BizField
    Required, Validator, Value, DefaultValue 
  • BizForm
    Link, Style, Hidden, Enabled, SelectFrom
  • BizForm.EventHandler
    Function, PostAction

字符

简单表达式语言定义以下字符:

  • 布尔: true, false
  • 整数: 和PHP一样
  • 浮点: 和PHP一样
  • 串: 用单引号和双引号; "是\", ' 是\ ', 并且\ 是\ \ 
  • Null: null

操作

简单表达式语言提供以下操作符:

  • 算术: +, - (binary), *, / 和 div, % 和 mod, - (一元)
  • 逻辑: and, &&, or, ||, not, !
  • 关系: ==,! =, <, >, < =, > = 。
  • 有条件: A? B: C. 根据A 的评估的结果, 评估B 或C。 

变量

  • 简单表达式允许开发商使用openbiz 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 SearchRule="[Start]>'date(\"Y-m-d\")'">
  • <BizDataObj AccessRule="[OwnerId]='{@profile:USERID}'">
  • <BizDataObj UpdateCondition="[OrgId]=={@profile:ORGID}">
  • <BizDataObj DeleteCondition="'admin'=={@profile:ROLEID}">
  • <BizField Name="NeedApprove" Required="{[Amount]>1500}"/>
  • <BizField Name="Fee" Validator="{[Fee]>=15}"/>
  • <BizField Name="FullName" Value="{[LastName]}, {@:Field[FirstName].Value}"/>

BizDataObj 的配置

BizDataObj xml 的DTD 文件被列出在附录A.1

BizDataObj 对表格映射

Openbiz 映射数据库表格到BizDataObj 对象。这个章节介绍BizDataObj与表格映射的概念, 下个章节"ORM" 有映射的配置的全面详细。BizDataObj 必须有表格名字和表格column 和 BizDataObj fields的映射。

  • 指定基本表格: 

<BizDataObj Name="BizDataObjName" Table="TableName" ...>

  • 映射 Column 到 BizField: 

    <BizField Name="FieldName" Column="ColumnName"....>. BizFields 必须有命名作为"Id" 。这必需"Id" 通常映射到表的主键.

  • 映射 SQL Function 到 BizField: 

    用户能将由数据库引擎提供的SQL function设给BizField。句法是< BizField Name="FieldName" Column= "" SQLExpr="FUNC([FieldName1]... [FieldName2 ]...)"> 。要保证Column属性是空的。例如: < BizField Name="FullName" Column= "" SQLExpr="CONCAT([FirstName ], ' ', [LastName ])"... > 。请注意SQLExpr 是询问相关的属性。[ FieldName ] 是询问语言的句法。

  • 指定BizField 的缺省值:

    <BizField Name="FieldName" Column="ColumnName" DefaultValue="default_value">. 使用DefaultValue 属性, 当dataobject 创造一个新纪录时, 会将缺省值设给BizField。

BizDataObj的查询语言

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" ...>

BizFields 的数据类型和格式

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) 映射

为支持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

映射表格到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>

主键(Id)的生成

从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" />
...

映射多表到BizdataObj

用户能通过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 中的对象. 

在BizDataObjs 之间一对多关系

在二个表之间一对多关系意味着表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 之间一对一关系

一对一关系是多对一关系的一种特殊情况

在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 和BizForm 配置

BizView metadata DTD 文件可能被发现在附录A.2 。

BizForm metadata DTD 文件可能被发现在附录A.2 。

BizView - HTML页面容器

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)

FMEvent as BizForm
 |-- BOEvent as BizDataObj
FMAttendeeChild as BizForm
 |-- BOAttendee as BizDataObj

基本BizForm 布局: 数据、工具栏和导航条

Openbiz BizForm 可分成三部份 - 数据部分、工具栏和导航条。

  • 数据部分是显示数据的区域。它可能被显示列单, 表单, 树等等。
  • 工具栏包含了BizForm 控制, 用户能从这些控制调用命令。
  • 导航条可以控制数据navigation 譬如换页, 卷动等。

这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>

以各种各样的HTML 元素表现数据

HTMLControl 或BizCtrl 可以指定元素类型和属性来, 以各种各样的HTML 元素表现它的数据。HTML 元素被显示在edit/query 模式下

BizForm 中 HTMLControl 元素属性

Type Width Height HTMLAttr* Style** SeclectFrom Caption Image 评论
Text x x x
Limit the input length
x       文本输入。默认类型
Textarea x x x x       多行的文本输入
RichText x x x x       Rich text editor edit HTML source
ListBox x x x
Show ListBox or ComboBox
x x
Set list of values
    ListBox or ComboBox
CheckBox x x x x x
Set True value
    复选框
Radio x
Arrange radio list 
x x x x
Set list of values
    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       Textbox with date picker icon
Datetime x x x x       Textbox with datetime picker icon
HTMLBlock x x   x   x
Special Characters
   HTML block
File x x x x       文件控制上装文件

* HTMLAttr 域可包含任一个合法的HTML 元素类型的HTML 属性

** Style 域可包含所有合法的样式 (css)

Limit the input length: 

HTMLAttr="maxlength=N" 限制用户能输入在文本控制字符的最大数字

Show ListBox or ComboBox: 

由缺省展示comboBox 。如果HTMLAttr="size=N", 显示N 列listbox

Set list of values: 

SelectFrom="XmlFile(Key)" 意味控制是listbox 或radio button. 数据是在XmlFile文件中所有的"Key" 元素

Set True value: 

SelectFrom="Value" 意味这当用户检查复选框时, 复选框返回"Value"

Arrange radio list: 

By default the radion buttons are arranged horiztionally. If Width="1", you can force them arranged vertically.

缺省radio 按钮横向安排。如果Width="1", 您可能迫使他们垂直安排了

Special characters:

在 HTML block 使用"<" and ">" , 必须由"&lt;" 和 "&gt;"替换。参见 http://www.w3schools.com/html/html_entities.asp 以获得详情。

Rich text editor

Openbiz rich text editor 主要使用Kevin Roth http://www.kevinroth.com/rte/demo.htm的代码 (LGPL license) . 感谢他的优秀工作。它支持IE5.5+ 并且Firfox 1.x. 如下是screenshot 。

Date/Datetime picker

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 另外的属性

  • FieldName - BizDataObj 的BizField 名字
  • DisplayName - BizField的标签, 可显示为表栏头
  • Link - 在READ显示方式之下, 控制的超链接. 一个例子: <BizCtrl Name="LName" FieldName="LastName" Link="a valid relative or absolute url"/>. 用户将看到 姓(即 Wilson) 链接 url.
  • DrilldownLink - 参见"配置drilldown 链接"
  • Sortable - 表明该领域是否可以排序
  • Order - BizCtrls 顺序
  • ValuePicker - 参见"配置BizCtrl 显示popup"

BizForm的事件处理 

当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 。"控制页面航海"会有解释

BizForm的键盘导航

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 中, 有通常一些控制依靠其它控制的值。当父控制变化, 它的子控制相应地变化。这是所谓的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中选择纪录 (见以下例子):

  • 加/更改子纪录(父子是M-1关系) 。
  • 选择一个现有的子纪录, 加入到子Form中(父子是M-M关系) 
  • 在被joined域上, 从被joined的dataobj 中选择一个纪录。

有二种方式配置记录选择的popup BizForm 。

  • 配置HTML 控制显示popup

配置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

配置BizCtrl 显示popup 从, 用户ValuePicker 属性

<BizCtrl Name="reg_attdln" FieldName="AttdLName" DisplayName="Last Name" ValuePicker="FMAttendeePopup"/>

在popup form, 增加一个按钮来调用JoinToParent(), 选择的纪录到父form 。

  • 为BizCtrl配置自动记录选择器

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

配置drilldown 链接对其它 view

您能配置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"/>

- 错误页和错误信息

如果执行中有错误, 应用会返退错误页或显示错误弹出窗口到浏览器

BizForm中的输入和输出 (Import and Export)

数据输入和输出的支持对离线用户很重要。离线用户通常在他们的膝上计算机执行应用在, 然后再与服务器数据库进行同步。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 支持以其它文件类型。

从BizForm上载文件

文件上载的支持在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 开发指南

请参阅Openbiz开发指南


附录 A - 第三方库

库名 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

附录 B - metadata DTD 文件

BizDataObj metadata DTD 文件

<!--OpenBiz BizObj metadata DTD-->

<!ELEMENT BizObj (BizFieldList, TableJoins, ObjRefernces, Parameters) >
<!ATTLIST BizObj Name CDATA #REQUIRED >
<!ATTLIST BizObj Description CDATA #REQUIRED >
<!ATTLIST BizObj Package CDATA #IMPLIED >
<!ATTLIST BizObj Class CDATA #REQUIRED >
<!ATTLIST BizObj InheritFrom CDATA #IMPLIED >
<!ATTLIST BizObj DBName CDATA #IMPLIED >
<!ATTLIST BizObj Table CDATA #REQUIRED >
<!ATTLIST BizObj SearchRule CDATA #IMPLIED >
<!ATTLIST BizObj SortRule CDATA #IMPLIED >
<!ATTLIST BizObj OtherSQLRule CDATA #IMPLIED >
<!ATTLIST BizObj AccessRule CDATA #IMPLIED >
<!ATTLIST BizObj UpdateCondition CDATA #IMPLIED >
<!ATTLIST BizObj DeleteCondition CDATA #IMPLIED >

<!ATTLIST BizObj CacheMode CDATA #IMPLIED >

<!ELEMENT BizFieldList (BizField+) >
<!ELEMENT BizField EMPTY >
<!ATTLIST BizField Name CDATA #REQUIRED >
<!ATTLIST BizField Class CDATA #IMPLIED >
<!ATTLIST BizField Join CDATA #IMPLIED >
<!ATTLIST BizField Column CDATA #REQUIRED >
<!ATTLIST BizField SQLExpr CDATA #IMPLIED >
<!ATTLIST BizField Type CDATA #IMPLIED >
<!ATTLIST BizField Format CDATA #IMPLIED >
<!ATTLIST BizField Required CDATA #IMPLIED >
<!ATTLIST BizField Validator CDATA #IMPLIED >
<!ATTLIST BizField DefaulValue CDATA #IMPLIED >
<!ATTLIST BizField Value CDATA #IMPLIED >
<!ATTLIST BizField OnAudit CDATA #IMPLIED >
<!ELEMENT TableJoins (Join+) >
<!ELEMENT Join EMPTY >
<!ATTLIST Join Name CDATA #REQUIRED >
<!ATTLIST Join Table CDATA #REQUIRED >
<!ATTLIST Join Column CDATA #REQUIRED >
<!ATTLIST Join JoinRef CDATA #IMPLIED >
<!ATTLIST Join ColumnRef CDATA #REQUIRED >
<!ATTLIST Join JoinType CDATA #REQUIRED >

<!ELEMENT ObjReferences (Object+) >
<!ELEMENT Object EMPTY >
<!ATTLIST Object Name CDATA #REQUIRED >
<!ATTLIST Object Description CDATA #IMPLIED >
<!ATTLIST Object Relationship CDATA #REQUIRED >
<!ATTLIST Object Table CDATA #REQUIRED >
<!ATTLIST Object Column CDATA #REQUIRED >
<!ATTLIST Object FieldRef CDATA #REQUIRED >
<!ATTLIST Object CascadeDelete CDATA #IMPLIED >
<!ATTLIST Object XTable CDATA #IMPLIED >
<!ATTLIST Object XColumn1 CDATA #IMPLIED >
<!ATTLIST Object XColumn2 CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

BizView metadata DTD file.

<!--OpenBiz BizView metadata DTD-->

<!ELEMENT BizView (ControlList, Parameters) >
<!ATTLIST BizView Name CDATA #REQUIRED >
<!ATTLIST BizView Description CDATA #REQUIRED >
<!ATTLIST BizView Package CDATA #IMPLIED >
<!ATTLIST BizView Class CDATA #IMPLIED >
<!ATTLIST BizView Template CDATA #IMPLIED >

<!ELEMENT ControlList (Control+) >
<!ELEMENT Control EMPTY >
<!ATTLIST Control Name CDATA #REQUIRED >
<!ATTLIST Control Form CDATA #REQUIRED >
<!ATTLIST Control SubCtrls CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

BizForm metadata DTD 文件

<!--OpenBiz BizForm metadata DTD-->

<!ELEMENT BizForm (BizCtrlList, DisplayModes, Toolbar, Navbar, Parameters) >
<!ATTLIST BizForm Name CDATA #REQUIRED >
<!ATTLIST BizForm Description CDATA #REQUIRED >
<!ATTLIST BizForm Package CDATA #IMPLIED >
<!ATTLIST BizForm Class CDATA #REQUIRED >
<!ATTLIST BizForm InheritFrom CDATA #IMPLIED >
<!ATTLIST BizForm jsClass CDATA #REQUIRED >
<!ATTLIST BizForm Title CDATA #REQUIRED >
<!ATTLIST BizForm BizDataObj CDATA #REQUIRED >
<!ATTLIST BizForm PageSize CDATA #REQUIRED >
<!ATTLIST BizForm SearchRule CDATA #IMPLIED >

<!ELEMENT BizCtrlList (BizCtrl+) >
<!ELEMENT BizCtrl (EventHandler+) >
<!ATTLIST BizCtrl Name CDATA #REQUIRED >
<!ATTLIST BizCtrl Class CDATA #IMPLIED >
<!ATTLIST BizCtrl FieldName CDATA #IMPLIED >
<!ATTLIST BizCtrl DisplayName CDATA #IMPLIED
>
<!ATTLIST BizCtrl Type CDATA #IMPLIED >
<!ATTLIST BizCtrl Width CDATA #IMPLIED >
<!ATTLIST BizCtrl Height CDATA #IMPLIED >
<!ATTLIST BizCtrl HTMLAttr CDATA #IMPLIED >
<!ATTLIST BizCtrl Link CDATA #IMPLIED >
<!ATTLIST BizCtrl Image CDATA #IMPLIED >
<!ATTLIST BizCtrl Hidden CDATA #IMPLIED >
<!ATTLIST BizCtrl Enabled CDATA #IMPLIED >

<!ATTLIST BizCtrl Sortable (Y|N) "" >
<!ATTLIST BizCtrl Order CDATA #IMPLIED >
<!ATTLIST BizCtrl Style CDATA #IMPLIED >
<!ATTLIST BizCtrl ValuePicker CDATA #IMPLIED >
<!ATTLIST BizCtrl SelectFrom CDATA #IMPLIED >
<!ATTLIST BizCtrl DrillDownLink CDATA #IMPLIED >
<!ATTLIST BizCtrl DisplayMode CDATA #IMPLIED >

<!ELEMENT Toolbar (Control+) >
<!ELEMENT Navbar (Control+) >
<!ELEMENT Control (EventHandler+) >
<!ATTLIST Control Name CDATA #REQUIRED >
<!ATTLIST Control Class CDATA #IMPLIED >
<!ATTLIST Control Image CDATA #IMPLIED >
<!ATTLIST Control Caption CDATA #IMPLIED >
<!ATTLIST Control Type CDATA #IMPLIED >
<!ATTLIST Control Width CDATA #IMPLIED >
<!ATTLIST Control Height CDATA #IMPLIED >
<!ATTLIST Control HTMLAttr CDATA #IMPLIED >
<!ATTLIST Control Style CDATA #IMPLIED >
<!ATTLIST Control Hidden CDATA #IMPLIED >
<!ATTLIST Control Enabled CDATA #IMPLIED >
<!ATTLIST Control SelectFrom CDATA #IMPLIED >

<!ATTLIST Control DisplayMode CDATA #IMPLIED >

<!ELEMENT EventHandler EMPTY >
<!ATTLIST EventHandler Name CDATA #REQUIRED >
<!ATTLIST EventHandler Event CDATA #REQUIRED >
<!ATTLIST EventHandler Function CDATA #REQUIRED >
<!ATTLIST EventHandler FunctionType CDATA #IMPLIED >
<!ATTLIST EventHandler ShortcutKey CDATA #IMPLIED >
<!ATTLIST EventHandler PostAction CDATA #IMPLIED >
<!ELEMENT DisplayModes (Mode+) >
<!ELEMENT Mode EMPTY >
<!ATTLIST Mode Name CDATA #REQUIRED >
<!ATTLIST Mode TemplateFile CDATA #REQUIRED >
<!ATTLIST Mode DataFormat CDATA #REQUIRED >
<!ATTLIST Mode FormatStyle CDATA #IMPLIED >

<!ELEMENT Parameters (Parameter+) >
<!ELEMENT Parameter EMPTY >
<!ATTLIST Parameter Name CDATA #REQUIRED >
<!ATTLIST Parameter Value CDATA #IMPLIED >
<!ATTLIST Parameter Required CDATA #IMPLIED >
<!ATTLIST Parameter InOut CDATA #IMPLIED >

Plugin service metadata DTD 文件

<!--OpenBiz Plugin service metadata DTD-->

<!ELEMENT PluginService ANY >
<!ATTLIST PluginService Name CDATA #REQUIRED >
<!ATTLIST PluginService Description CDATA #IMPLIED >
<!ATTLIST PluginService Package CDATA #REQUIRED >
<!ATTLIST PluginService Class CDATA #REQUIRED >

Openbiz 2.0 中文手册(二)

这份文件是openbiz2.0中文手册(二)

Openbiz 开发指南


Openbiz 开发指南

Show openbiz views (pages)  - 尚待翻译...

- 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".
operator can be =,>,>=,<,<=,!=. "LIKE %" SQL format is also valid rule. "AND", "OR" can be used to add more restriction.

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  

Build view and form web templates

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".

- Draw BizForm as a html table

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

- Draw BizForm as a set of controls

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

Using BizDataObj functionalities

Only basic usage of BizDataObj is listed below. Please refer to the API doc for details.

Query and get results

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, Update and Delete a record 

// 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();

Using BizForm functionalities

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

  • SearchRecord - show the query record mode
  • RearchRecord - Issue the query with user input in query mode and return to read mode

Insert a new record

  • NewRecord - show the new record mode
  • SaveRecord - Save current edited record with user input in query mode and return to read mode

Update a record

  • EditRecord - show the edit record mode on current focus record
  • SaveRecord - Save current edited record with user input in query mode and return to read mode

Delete a record

  • DeleteRecord - delete the current focus record

Copy a record

  • CopyRecord - copy the current focus record to new record

Page Navigation

  • MoveNext - show next page records
  • MovePrev - show previous page records

User input validation

According the topic at http://www.boringguys.com/?p=30, there are 3 different types of data validation checks one can do:

  • Syntactic validation - check data syntax 
  • Semantic validation - check one piece of data makes sense in regards to other incoming data
  • Domain or model validation - check data against another source of acceptable values

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.

Client side form validation

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 *"

Server side input validation

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.

Extend OpenBiz classes

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.

Extend server side classes

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()
}

Extend client side classes

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:

  • CallFunction(method, params_array) - convert function to request and send it to server. A server side BizForm method is invoked by this method if there's no specific method implemented in the client class. For example, a BizForm, whose jsClass=jbForm, has a method named "SelectRecord". Openbiz will check if "SelectRecord" method is defined in jbForm class. If yes, it calls jbForm's SelectRecord(params_array), otherwise it calls CallFunction(method, params_array).
  • CallbackFunction(retContent) - Ajax callback function. It passes the returned content to Show().
  • CollectFormData() - collect form data into a message in Ajax call
  • Show(retContent) - called by callback function to show Ajax returned content in the form

jbForm methods:

  • CollectFormData() - overriding AjaxForm CollectFromData(), add additional "selected row" in the form data
  • SelectRecord(params_array) - special logic on select record call
  • SortRecord(params_array) - special logic on sort record call
  • DeleteRecord(params_array) - special logic on delete record call

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);
}

Implement Plug-in Service

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/.

  • excelService.php - print Excel output with HTML or CSV formats
  • authService.php - authentication service, please refer to next chapter for usage
  • accessService.php - view access control service, please refer to next chapter for usage
  • profileService.php - user profile service, please refer to next chapter for usage
  • logService.php - write log to file
  • ioService - data winput/output service
  • pdfService.php -  prints PDF report
  • emailService.php - integrated with PHPMailer to send emails through smtp mail server.
  • doTriggerService - BizDataObj trigger service
  • auditService - audit trail service to trace data change

In the application, you can specify your own plugin service implementation with following methods.

  1. Change the service metadata content under your_app/metadata/service/, still use the core service. For example, you can write different accessService.xml to control the view access rule, but the implementing class is accessService.php in core library. The accessService.xml is like 
    <PluginService Name="accessService" Package="service" Class="accessService">
       application specific view access definition
    </PluginService>
  2. Specify the service implementing class. For example, different applications have different profile service. The profileService.xml is like 
    <PluginService Name="profileService" Package="service" Class="your_own_service_class">
    </PluginService>
  3. Combine the above 2 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

  • Call service in form. Define the caller function in BizForm metadata file
    <... Function="CallService(ClassName,MethodName)"...> is to call a method "MethodName" of the service "ClassName". ClassName is a class which defined in ClassName.php under bin/usrlib/ directory
  • Call service with url. Use url like bin/BizController.php?F=Invoke&P0=[servicename]&P1=[methodname]&P2=[parameter1]... The example is bin/BizController.php?F=Invoke&P0=[pdfService]&P1=[renderView]&P2=[demo.ReportView]
  • Call service in code. 
    global $g_BizSystem;
    $svcobj = $g_BizSystem->GetService($class);
    $svcobj->$method($this->m_Name);

Implement authentication, view and data access control

User authentication

Openbiz uses authentication service (usrlib/authService.php) to authenticate username and password

public function AuthenticateUser ($userid, $password) is called to authenticate user. 

  • AuthenticateUser by default querys on "User Id" and "Password" fields defined in metadata/shared/BOAuth.xml. If input user id and password is found in in BOAuth, AuthenticateUser returns true. AuthenticateUser method is to be modified to fit customer logic.
  • metadata/shared/SignupView.xml is the default login view. This view can be configured for change the login look and feel.

Role-based view access control

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.

  • Customer must replace the default GetProfile method in openbiz package, because the default GetProfile method returns some randomly made array.

public function AllowViewAccess ($viewName, $role=null) is called to check the accessibility of a view

  • accessService has a configuration file (accessService.xml) that defines the view access permission. Please see an example below.

  • The xml configuration file is easy to understand. Customer needs to put their own logic in the accessService.xml.

Attribute-based data access control

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}"

Build a multi-step wizard view

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:

  • Each form has "Next", "Back", "Cancel" and "Finish" navigation buttons.
  • If user clicks cancel button, user input data is not saved to database.
  • User input data won't to commit to database until user clicks finish button.

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

Configuration of wizard view

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>

Configuration of wizard forms

A wizard form is a regular form with class as BizFormWizard or BizFormNewWizard (or their subclasses).

  • BizFormWizard - to edit a record
  • BizFormNewWizard - to create a record

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="&lt; Back" Type="Button" Function="GoPrev()" />
    <Control Name="btn_next" Image="" Caption="Next &gt;" 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>

Extend wizard with customer wizard class

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.

Implement dataobject events trigger

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.

Define a dataobject trigger metadata

<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

Make customer specific UI components

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.

Tabs component

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. 

Menu component 

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.

Tree component

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.

Control the look and feel with css files

The openbiz look and feel is controlled by stylesheet css files. The main css file is /css/openbiz.css

Control BizForm table style

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 {...}

Control tabs style

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 {...}

Control menu style

In order to give user specific tab styles, users can modify the following section in css/menu.css file.

Control tree style

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 {...}

Control rich text editor (RTE) style

In order to give user specific RTE styles, users can modify the following section in pages/rte/rte.css file.

Date and Datetime picker

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.

Debug strategies

- 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.

API document

Openbiz 2.0 API document

中文Powerpoint 教程

下载 中文Powerpoint 教程 

Openbiz Eclipse插件用户手册

Openbiz Eclipse插件用户手册

  1. 安装
  2. 在openbiz 项目上工作
    2.1 创造openbiz 项目
    2.2 创造和编辑BizObj
    2.3 创造和编辑BizForm
    2.4 创造和编辑BizView
    2.5 在浏览器测试BizView 

1. 安装

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。

在config.xml中预设的数据库元素

<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"/>

配置数据库元素, 以下属性必须正确地被设定。

  • DriverFile - jdbc driver jar file 路径
  • DriverClass - jdbc driver 类
  • ConnectURL - 连接数据库服务器jdbc 的 URL
  • Schema - schema 名字. 一些数据库类型(如Oracle) 支持。
  • User - 连接到数据库服务器用户名
  • Password - 连接到数据库服务器密码

2. 在openbiz 项目上工作

2.1 创建openbiz 项目

在 Eclipse 的帮助下, openbiz 的目录可被 eclipse 项目(project)管理. 用户可创建一个指到openbiz 应用目录(或 openbiz/metadata) 的项目. Openbiz project 树会出现在 eclipse Navigator view. 见下图

2.2 创建一个 BizDataObj - 映射到数据库表的对象

从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizDataObj metadata file.

 

然后在后面的页上做以下任务。

  1. 键入metadata 文件名
  2. 从config.xml 的数据库名单中选择一个数据库
  3. 选择一张数据库表为BizDataObj 基本的表
  4. 选择表栏(table columns)映射到BizFields

在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。编辑看起来象eclipse Plug-in Menifest 编辑。概要页显示根metadata 对象, 其他页展示xml 树第二层次xml 元素的信息。见下图

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

  • 增加, 删除或移动元素
  • 在editbox键入值或在comboBox选择值
  • 点击"..."按钮, 选择一个值, 譬如 table, column 或metadata 对象

2.3 创建BizForm - 对应于BizDataObj 的界面对象

像创建 BizDataObj 一样, 从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择 New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizForm metadata file.

然后在后面的页上做以下任务。

  1. 键入metadata 文件名
  2. 选择一个BizForm 依赖的BizDataObj 
  3. 选择BizDataObj's BizFields 映射到BizForm's BizCtrls
  4. 创建Toolbar 控制的Navigation bar 控制
  5. 为controls and BizCtrls 加上event handlers

在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。

Screenshot: 用鼠标右键单击控制, 从菜单项目增加EventHanlder

Screenshot: 编辑控制的event handler

2.4 创造和编辑BizView - BizForm 的容器

像创建 BizDataObj 一样, 从主菜单上点击 File -> New -> Others... , 或用鼠标右击 openbiz project, 选择New -> Others..., 一个窗口会弹出. 选择Openbiz Metadata Object -> BizView metadata file.

然后键入metadata 文件名, 点击结束按钮

在您点击结束按钮之后, 新metadata 文件被打开在编辑区域。

2.5 在浏览器中测试BizView

BizView 可以用以下url 格式:

openbiz_root_path/bin/controller.php?view=package.viewname

例如, http://localhost/demoapp/bin/controller.php?view=shared.SignupView