Show openbiz views (pages)- User URL string as controller.php?view=...&form=...&rule=...&mode=...&OtherInputs... - Use client javascript GoToView(view, rule, loadPageTarget)
Build view and form web templatesSmarty 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 tableIn BizForm xml file, you need give DataFormat as "block" and FormatStyle as table style which is given in css file. 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 controlsSince 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
Using BizDataObj functionalitiesOnly basic usage of BizDataObj is listed below. Please refer to the API doc for details. Query and get results
Insert, Update and Delete a record
Using BizForm functionalitiesUser can configure function in BizForm metadata file to invoke appropriate action on server side. The commonly used BizForm methods are listed below. Please refer to the API doc for details. Query and show results
Insert a new record
Update a record
Delete a record
Copy a record
Page Navigation
User input validationAccording the topic at http://www.boringguys.com/?p=30, there are 3 different types of data validation checks one can do:
Syntactic and semantic validation can be implemented on client side and service side. Domain validation involves query data source, it is usually done in service code that connects to database. Client side form validationOpenbiz 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 validationOpenbiz 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 classesOpenBiz 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 classesBecause 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
Example: Extend BizDataObj and BizForm /** function my_special_function() {} // new function /** function my_special_function() {} // new function function Render() {} // override Render() Extend client side classesBizForm is the main server side presentation class, it has its counterpart class on client browser side. In the BizForm metadata, users can specify client side class in jsClass attribute of BizForm element. For example. <BizForm Name="FMEvent" ... Class="BizForm" jsClass="jbForm"...> Openbiz provides two client side classes AjaxForm and jbForm that is a subclass of AjaxForm. AjaxForm methods:
jbForm methods:
To implement UI logic on client side, developers need to create their own client side class like jbForm and give the class name to jsClass attribute of BizForm element. If you need special logic in some methods, add these methods in the client class, which can be subclass of either AjaxForm or jbForm. These methods can be pure client code or it can this.CallFunction(...) to send the request to server. An example: Form metadata file is like:
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:
Implement Plug-in ServiceOpenbiz customer can write their special logic by implement Plug-in Service. Plugin services are also metadata-driven objects. Service code is under bin/service and metadata is under /metadata/service. The plugin service metadata only gives the service name, package and implementing class. Any xml elements can be child of the root PluginService element. This is because different services may have different metadata configuration. Please refer to the Appendix to see the DTD of plugin service metadata xml file. Openbiz core library includes services under openbiz/bin/service/ and their metadata files under openbiz/metadata/service/.
In the application, you can specify your own plugin service implementation with following methods.
Write a plug-in service Implement the class and method in the ClassName.php class pdfService function renderView($viewName) Call a plug-in service method
Implement authentication, view and data access controlUser authenticationOpenbiz uses authentication service (usrlib/authService.php) to authenticate username and password public function AuthenticateUser ($userid, $password) is called to authenticate user.
Role-based view access controlView access control depended on the AccessControl attribute in view metadata file in Openbiz 1.x. From Openbiz RC1, openbiz implements role-based view access control in its new security architecture. Openbiz uses profile service (usrlib/profileService.php) to get user profile that includes "role". Then match this role to access service (usrlib/accessService.php) to determine the users' accessibility to the view public function GetProfile ($userid=null) is called to get user profile array which is an associated array with profile key and profile value pairs.
public function AllowViewAccess ($viewName, $role=null) is called to check the accessibility of a view
Attribute-based data access controlOpenbiz 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.
- 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 viewWizard is a sequence of forms (questionnaires) which guide users to complete a complicated task. An example is filling an expense report which include different types (hotel, airfare, other activities...) of expenses. Openbiz support wizard by easy metadata configuration. Openbiz wizard has following features:
To see sample of wizards, go to Test view, click on "Wizard tests +" submenus. As you can see from the demo, wizard can be accessed with an url.
As shown in the 2nd link, developer can give the parameter on the fly to run the wizard against given record Configuration of wizard viewOpenbiz 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"?> Configuration of wizard formsA wizard form is a regular form with class as BizFormWizard or BizFormNewWizard (or their subclasses).
This is a typical wizard form metadata file. <?xml version="1.0" standalone="no"?> Extend wizard with customer wizard classIf 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 triggerUpon 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">
Make customer specific UI componentsDue 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 componentThis 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"?> 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 componentOpenbiz 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"?> 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 componentOpenbiz 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"?> 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 filesThe openbiz look and feel is controlled by stylesheet css files. The main css file is /css/openbiz.css Control BizForm table styleIn case of using Format="block" in the BizForm's displayMode, users can modify the following section in css/openbiz.css file. /* -------- table style -------- */ Control tabs styleIn order to give user specific tab styles, users can modify the following section in css/openbiz.css file. /* -------- tabs style -------- */ Control menu styleIn order to give user specific tab styles, users can modify the following section in css/menu.css file. Control tree styleIn order to give user specific tree styles, users can modify the following section in css/openbiz.css file. /* ----- tree style ----- */ Control rich text editor (RTE) styleIn order to give user specific RTE styles, users can modify the following section in pages/rte/rte.css file. Date and Datetime pickerThe 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.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

