Makumba in Java Server Pages#

Makumba offers a JSP custom tag library, that allows easy interaction (viewing, editing) with the data in your database, right from your HTML (actually, JSP) document. Since Makumba pages, are essentially JSP pages, a basic understanding of JSP will be helpful to make more advanced use of makumba. Same goes for knowing a bit of Java itself. But you can get a long way with just a few notions! Really.

Makumba tags are written according to Servlet 2.4 specification and JSP 2.0 specification. You will need a so-called "servlet container" that supports them both, such as Apache Tomcat. The corresponding WEB-INF/taglib.tld is already included in the distribution makumba.jar.

Before using Makumba tags in your JSP pages you also need to declare the taglib with:

<%@ taglib uri="" prefix="mak" %> 

A few resources on JSPs (don't be afraid to try first, read later) :

JSP tag parameters#

JSP-tag parameter values are either FIXED or RTEXPR (runtime expression). A FIXED tag parameter must have a constant, literal value, while an RTEXPR can also be of the form <%= java_expression %>. On the other hand, some FIXED parameters can contain jsp attributes like $attr in makumba tags.

All parameters are optional unless specifically mentioned as being mandatory.

Specific concern can be the parameter quoting. Tag parameters can be written as name="value" or name='value' (note: the stringLiteral on DATE must be quoted with "). The choice of quote can be determined by the need to use either double or single quote as part of the value itself. If the quote is also present within the value, it must be escaped by a backslash.

<mak:list from="general.Person p" where="p.gender=\"male\"" >
<mak:list from="general.Person p" where='p.gender="male"' >
<mak:list from="general.Person p" where="p.gender='male'" >
<mak:list from="library.Book b" where="b.publisher=\"O'Reilly\" " >
<mak:list from="library.Book b" where='b.publisher="O\'Reilly" ' >}]
Quotes in extra HTML formatting parameters, such as styleClass, title, styleId, onClick ... need some special attention with quotes. The parameter values are copied verbatim (with no modifications by makumba) to the resulting HTML, always surrounded with double quotes ("). This means that you have to use other quotes, like single one ('),

If you need to pass a literal backslash (\) you have to escape it with a preceeding backslash (\\).

<mak:input ... onClick="alert(this.value);"/>
<mak:input ... onClick="alert('Hello world!');"/> 
<mak:input ... onClick="alert('Hello\\nWorld');"/>

Unfortunately the idea to use a sequence of escapes, eg writing \\\' in the JSP page to set the tag attribute to \', which could be handy for javascript tag attributes, is confusing the Tomcat servlet container.

Category Documentation

Add Comment
« This page was last updated on May 16 2010