Sunday, February 21, 2010

Cubi clean url

In Openbiz baseapp, a typical url to access a view is like http://host/baseapp/bin/controller.php?view=a.b.viewname. We call it raw openbiz url.

Cubi will map cleaner urls to raw urls by adding an index.php and .htaccess under the root directory of cubi installation.

View mapping syntax:
  • /cubi/a/x maps to /cubi/bin/controller.php?view=a.view.XView. Example: /cubi/system/userList
  • /cubi/a/x_y maps to /cubi/bin/controller.php?view=a.view.XYView. Example: /cubi/system/user_list
  • /cubi/a/x/number maps to /cubi/bin/controller.php?view=a.view.XView&fld:Id=number. Example: /cubi/system/user_detail/5
  • /cubi/a/x/word_number maps to /cubi/bin/controller.php?view=a.view.XView&fld:word=number
If .htaccess is not recognized by web server (e.g. installed on IIS), then you need to do the following:
  • Add "?" right after /cubi/. This assumes that index.php is the default script configured in web server. For example, http://host/cubi/?/system/user_list
  • Or add "index.php?" right after /cubi/. For example, http://host/cubi/index.php?/system/user_list

Saturday, February 20, 2010

Cubi new openbiz.js

In previous openbiz baseapp, clientUtil.js is the main js library to support openbiz browser end logic. It handles Ajax call, form behavior, popup, dialog, richeditor, auto suggestion ... When more functions are inserted in the js file, the code get more messy. Cubi replaces clientUtil.js with openbiz.js in order to get the browser code more organized.

The code structure in openbiz.js
  • Openbiz - main Openbiz namespace. It manages the form objects and provide entry of openbiz ajax call
  • Openbiz.ActionType. It defines the action types of openbiz ajax call.
  • Openbiz.Form. Each openbiz form instance will have a javascript Openbiz.Form instance
  • Openbiz.TableForm. This is the js instance of openbiz List/grid form.
  • Openbiz.Net. It provides network related functions like ajax call.
  • Openbiz.Window. It manages popup, dialog logic.
  • Openbiz.Util. It has some utility functions.
  • Openbiz.Menu. It has functions to show and hide context menu
  • Openbiz.CKEditor. It has functions that integrate CKEditor with ajax call.
  • Openbiz.AutoSuggest. It has functions that initiates autosuggestion control
  • Openbiz.Validator. It has functions that validate user entries on client side only.
With the replacement of clientUtil.js to openbiz.js, there will be some change needed on the existing template, code that worked with clientUtil.js. For example.
  • Replace CallFunction with Openbiz.CallFunction in the list template file
Most changes are done in the openbiz code already to work with the new openbiz.js.

Openbiz.js introduce another importance changes.
  • User JSON in all ajax call.

Cubi metadata naming convention

Before Cubi, Openbiz developers can name their metadata with any name. For example, an user list form can be named as
  • FM_UserList.xml
  • f_userlist.xml
In Cubi, metadata name follows the syntax as "NameType". For the user list form, Cubi will use
  • UserListForm.xml
The advantage of this name besides its clarity is that its custom form class can have the same name. To define a custom class, you just need to set
in the UserListForm.xml
Then add UserListForm.php in the same directory.

Sample metadata names from Cubi/modules/system directory
For DataObject metadata
/do/UserDO.xml
/do/RoleDO.xml

For Form metadata
/form/UserListForm.xml
/form/UserEditForm.xml
/form/UserNewForm.xml

For View metadata
/view/UserListView.xml
/view/UserEditView.xml
/view/UserNewView.xml