Makumba Business Logic (BL) is executed at form submission time. It makes it possible to perform additional validation, data manipulation and other processing tasks. Makumba BL is associated with JSP pages through a special discovery mechanism, and further through the usage of so-called handler methods. Data manipulation can be performed using the most important makumba API elements.

Business Logic discovery#

Each JSP page will determine its handler class on first access, after being compiled. If the class changes on disk, a web-app reload is generally needed for the new class to take effect.

The handler is "discovered" by decomposing the full path of the JSP page, and finding a class with a matching name. Decomposition breaks the full path at every capital letter, or forward slash. For example, with the page path /employee/profile/personalProfile.jsp, the following criteria are applied, in order:

Criterion Java classes checked for
page name EmployeeProfilePersonalProfileLogic
caps parts of page/directory name EmployeeProfilePersonalLogic
directory name EmployeeProfile
parent directory name(s) EmployeeLogic, Logic

The class name prefix (e.g. java package name) can be regulated per parts of the site in in the Makumba.conf configuration file, in the [businessLogicPackages] section. For example, the section can contain:

/employee = org.myCompany.employee
/makumba = org.makumba

path Java classes checked for
/employee/profile/index.jsp org.myCompany.employee.ProfilePersonalProfileLogic
/makumba/tests/x.jsp org.makumba.TestsXLogic
/some.jsp test.SomeLogic

There are good reasons to take into account the name of the response page of a form when looking for the business logic. Still, it is the name of the page that contains the form which matters, not the name of the action page. It is good practice for both pages to actually have the same handler class.

Business Logic handler methods#

On form submission, the data in the form can be accessed for validation and processing purposes. Depending on the action at hand, there are different kind of generic handlers that can be used. It is also possible to define custom handlers.


See the makumba API documentation to learn more about the makumba API elements.

Generic handler methods#

These are the handlers used by mak:newForm, mak:editForm, mak:addForm and mak:delete. Their name is constructed on the handler type, the action type, and the type of the MDD that is being processed by the form.

When creating, editing, adding to and deleting the type company.Project, the generic handler methods are:

action generic handler methods
new on_newCompanyProject(Dictionary<String, Object> d, Attributes a, Transaction t) {}
after_newCompanyProject(Pointer p, Dictionary<String, Object> d, Attributes a, Transaction t) {}
add on_addCompanyProject(Pointer p, Dictionary<String, Object> d, Attributes a, Transaction t) {}
after_addCompanyProject(Pointer p, Dictionary<String, Object> d, Attributes a, Transaction t) {}
edit on_editCompanyProject(Pointer p, Dictionary<String, Object> d, Attributes a, Transaction t) {}
after_editCompanyProject(Pointer p, Dictionary<String, Object> d, Attributes a, Transaction t) {}
delete on_deleteCompanyProject(Pointer p, Attributes a, Transaction t) {}
after_deleteCompanyProject(Pointer p, Attributes a, Transaction t) {}

These methods make it possible to access the form data contained in the Dictionary object and the page and request data held by the Attributes object. Additional queries and/or operations on the database can be performed using the Transaction, whilst the Pointer is a relational object that uniquely identifies the record that is being manipulated.

Custom handler methods#

When using the mak:form tag, it is possible to define custom handler methods by specifying their name in the handler attribute of the tag.

These handler methods need to have the following signature

public void handlerMethod(Dictionary<String, Object> formFields, Attributes restOfArguments, Transaction t) { }

The handler can then be placed in the Business Logic file corresponding to the page.

Category Documentation

Add Comment
« This page was last updated on July 21 2010