The Open For Business JSP Tag Library consists of a set of custom tags that make it easier to use other components of the OFBiz Core Framework.
While there are some basic conditional, flow control, i18n and other general tags included in the library many of these can be found in other more generalized tag library like the Jakarta library. They are mainly included here for convenience and have defaults that are more friendly for use in the OFBiz framework.
The following table presents a list of the OFBiz tags and some basic information about them for reference. The rest of the document explains each tag in detail.
Tag Name | BodyContent | Tag Class | TEI Class |
url | JSP | UrlTag | |
contenturl | JSP | ContentUrlTag | |
if | JSP | IfTag | |
unless | JSP | UnlessTag | |
iterator | JSP | IteratorTag | IteratorTEI |
iteratorNext | JSP | IterateNextTag | IterateNextTEI |
iteratorHasNext | JSP | IteratorHasNextTag | |
format | JSP | FormatTag | |
empty | PrintTag | ||
field | empty | EntityFieldTag | |
entityfield | empty | EntityFieldTag | |
inputvalue | empty | InputValueTag | |
i18nBundle | JSP | I18nBundleTag | |
i18nMessage | JSP | I18nMessageTag | |
i18nMessageArgument | empty | I18nMessageArgumentTag | |
service | JSP | ServiceTag | |
param | empty | ParamTag | |
object | JSP | ObjectTag | ObjectTEI |
ofbiz:url
Add control path and URL encode if necessary. This is for links to dynamic pages in the same webapp and the body is meant to contain a forward slash ("/") and then the name of a request defined in the controller.xml file. Parameters should also be included inside the tag.
The tag will automatically insert the mounting point of the current webapp and the mounting point of the control servlet.
The tag will also create a secure (HTTPS) URL (a URL that refers to the secure port on the server) to automatically go from insecure to secure areas, and will create an plain or non-secure (HTTP) URL to automatically go from secure to insecure areas of the site. This is configured in the url.properties file. See the Core Configuration Guide for more details.
This tag has no attributes.
ofbiz:contenturl
Builds a URL for content referred to by this page. This is generally for static content such as images that can be stored on a different server. So, if necessary it will create a complete URL for the static content and is takes into account whether the content should be referred to securely (with HTTPS) or not (with HTTP).
This is also configured in the url.properties file as described in the Core Configuration Guide.
This tag has no attributes.
ofbiz:if
Processes the body content of the tag if the named attribute value exists and if it meets any size and value conditions specified.
Attribute Name | Required? | ExprVal? | Description |
name | Y | Y | The name of the page, request, session, or application attribute to use for the comparison. |
type | N | N | The type of the attribute Object. It is not necessary to specify this because the tag will test the type of the object at runtime. Only necessary if the default behavior does not behave as desired. |
value | N | Y | If specified the named attribute value will be compared to this value.
Can be specified using the <%=...%> syntax to refer to
an existing object declared within the JSP. |
size | N | N | If specified this value will be compared to the size of the named attribute value. This is mostly applicable for type such as Collections, Maps, Strings, etc. |
ofbiz:unless
Does the exact opposite of the if tag. In other words the body content will be evaluated if the named attribute value does not exist or if it does exist but does not meet the size and value conditions.
The attributes of the unless tag are the same as the attributes of the if tag. Refer to the table above in the if tag section for detailed information on these attributes.
ofbiz:iterator
The iterator tag iterates over a collection of elements in a collection object in a named attribute. The individual elements are placed in a pageContext attribute, and made available in the JSP Java context for use in scriptlets.
Attribute Name | Required? | ExprVal? | Description |
name | Y | N | The name of the attribute that the collection of elements will come from. Can be in the page, request, session or application contexts. |
property | N | N | The name of the attribute and Java variable that the individual elements will be put into as the iterator iterates. |
type | N | N | The type of the elements within the collections. This must be specified so that the Java context variable can be created. Defaults to org.ofbiz.entity.GenericValue, which is one of the more common objects to iterate over in OFBiz framework based applications. |
expandMap | N | N | If expandMap is true then the iterator elements must implement the Map interface the the keys in the Map entries must be Strings. Each map entry will be put into the pageContext if this is set using the Map key value as the attribute name. Must be true or false. Defaults to false. |
offset | N | Y | If specified the iteration will start at the given offset index instead of at the beginning of the collection. |
limit | N | Y | If specified only the specified number of iterations will be done. In other words this limits the number of elements pulled from the iterator. |
Sub-Element Name | How Many | Description |
iterateNext | 0 to many | Descibed below. |
iteratorHasNext | 0 to many | Descibed below. |
ofbiz:iteratorNext
Grab the next element in the collection of the parent iterator tag.
Attribute Name | Required? | ExprVal? | Description |
name | N | N | The name of the attribute to put the element in. Defaults to the name specified in the property attribute of the parent iterator tag. |
type | N | N | The type of the elements within the collections. This must be specified so that the Java context variable can be created. Defaults to org.ofbiz.entity.GenericValue, which is one of the more common objects to iterate over in OFBiz framework based applications. |
expandMap | N | N | If expandMap is true then the iterator elements must implement the Map interface the the keys in the Map entries must be Strings. Each map entry will be put into the pageContext if this is set using the Map key value as the attribute name. Must be true or false. Defaults to false. |
ofbiz:iteratorHasNext
Only process body if parent iterator tag has another entry.
This tag has no attributes.
ofbiz:format
Formats dates, numbers and currencies from the value in the body of the tag. It has one attribute that specifies how the text should be formatted.
Attribute Name | Required? | ExprVal? | Description |
type | N | N | Specified how the type of format to apply to the body value. Must be "currency", "number", or "date". If not type is specified the original value is printed. |
ofbiz:print
Prints an attribute from the pageContext. If null prints the default value or nothing if no default is specified.
Attribute Name | Required? | ExprVal? | Description |
attribute | Y | Y | The name of the attribute to print. |
default | N | Y | The default value to print if the specified attribute is not found. |
ofbiz:field
Displays a properly formatted string from field in the specified attribute.
Attribute Name | Required? | ExprVal? | Description |
attribute | Y | N | The name of the attribute that contains the field to print. |
type | N | N | Optionally specifies the type of the field to print. Can be "currency" or any of the Java field types. If not specified the tag will automatically determine the Java type. |
default | N | Y | The default value to print if the specified field is not found. |
prefix | N | N | If the resulting message is not empty this string will be printed before the field value. |
suffix | N | N | If the resulting message is not empty this string will be printed after the field value. |
ofbiz:entityfield
Displays a properly formatted localized string from a field in the entity in the specified attribute. The prefix and suffix attribute contents will print before/after if the field is not null or empty.
Attribute Name | Required? | ExprVal? | Description |
attribute | Y | N | The name of the attribute that contains the entity that contains the field to print. |
field | Y | N | The name of the field to print in the named entity. |
type | N | N | Optionally specifies the type of the field to print. Can be "currency" or any of the Java field types. If not specified the tag will automatically determine the Java type AND get additional type information from the Entity Engine field definition for this field. With that information currency will automatically be formatted as currency. |
default | N | Y | The default value to print if the specified field is not found. |
prefix | N | N | If the resulting message is not empty this string will be printed before the field value. |
suffix | N | N | If the resulting message is not empty this string will be printed after the field value. |
ofbiz:inputvalue
Outputs a string for an input box from either an entity field or a request parameter. Decides which to use by checking to see if the entityAttr exists and using the specified field if it does.
If the Boolean object referred to by the tryEntityAttr attribute is false, always tries to use the request parameter and ignores the entity field.
Formatting is done with a very simple toString.
The Object found by looking up the context attribute with the name specified by entityAttr can be either a GenericValue object, or any implementation of the Map interface.
Attribute Name | Required? | ExprVal? | Description |
field | Y | N | The name of the field to print in the named entity. |
param | N | N | The name of the URL parameter that corresponds to this value. If null or empty param will be the same as field. |
entityAttr | Y | N | The name of the attribute that contains the entity that contains the field to print. |
tryEntityAttr | Y | N | The name of an context attribute that contains a Boolean which specifies whether or not to even try using the named entity. If false the request parameter value will be used, if true the entity field value will be used. |
default | N | Y | The default value to print if the specified entity field or parameter is not found. |
fullattrs | N | N | If fullattrs is set to true then [name="{param}" value="{value}"] will be output instead of just [value]. By default fullattrs is false. |
ofbiz:i18nBundle
Used to specify and load an internationalized message bundle. The bundle will be referred to by the id attribute value if specified. By default all messages will be retreived from the bundle specified by their parent i18nBundle tag, in other words the i18nMessage tags will be nested inside the bundle tag.
Attribute Name | Required? | ExprVal? | Description |
id | N | Y | An ID that can be used later in the bundleId attribute of the i18nMessage tag to refer to this bundle. |
baseName | Y | Y | The resource base name of the message bundle. Generally the name of a .properties file, but specified without the .properties extension. |
ofbiz:i18nMessage
Prints an internationalized message from the parent or specified bundle identified by the given key. Accepts message arguments using nested i18nMessageArgument tags.
Attribute Name | Required? | ExprVal? | Description |
key | Y | Y | The key or ID of the message within the bundle. |
bundleId | N | Y | The ID of the bundle to get the message from. If not specified looks for the parent i18nBundle tag and uses that bundle. |
ofbiz:i18nMessageArgument
Specifies an agrument for the parent i18nMessage tag. The arguments will be numbered in the order they are specified.
Attribute Name | Required? | ExprVal? | Description |
value | Y | Y | The value of the argument to insert into the message. Can use the
<%=...%> syntax to use Java method context variables. |
ofbiz:service
The service tag invokes the named service using the given mode (sync or async). The results can be placed in the page, request, session or application scope as specified using the resultTo attribute. The default scope is page.
To specify information about parameters and return values use nested param tags. They are described below.
For more information on services see the Service Engine Guide and the Service Engine Configuration Guide.
Attribute Name | Required? | ExprVal? | Description |
name | Y | Y | The name of the service to call. |
mode | N | Y | The mode that will be used to call the service, either synchronous or asynchronous. Must be sync or async, Defaults to sync. |
resultTo | N | Y | Specifies the scope that the results should be put into. The OUT attributes/parameters of the service will be put into attributes in this scope. Must be page, request, session or application. Defaults to page. |
ofbiz:param
The param tag is used to specify information about parameters passed to the service and can also be used for spcifying certain information about return values.
Attribute Name | Required? | ExprVal? | Description |
name | Y | Y | The name of the service parameter. |
value | N | Y | The value to assign to an IN parameter. Can use the
<%=...%> syntax to use Java method context variables. |
mode | N | Y | Specifies the mode of the parameter. Must be IN, OUT or INOUT. Defaults to IN. If OUT or INOUT the alias attribute can be used to override the default key for the context attribute in the scope specified in the service tag. |
map | N | Y | Specifies a name for a Map to find in a context attribute. If specified the attribute attribute will be used to find a value in this map. If not specified the attribute attribute will be used to lookup a value in a context attribute. |
attribute | N | Y | Specifies the name of the attribute value to lookup. This is used INSTEAD of the value attribute which is used to directly specify the value to be passed to the service for this parameter. The looked up attribute value will be passed to the service for this parameter. |
alias | N | Y | Used to specify the key that will be used when putting OUT or INOUT parameters into a context attribute. Defaults to the value of the name attribute. |
ofbiz:object
Makes an Object in a context attribute (page, request, session or application) available in the Java method context of the JSP so it can be used in Java scriptlets, etc.
Attribute Name | Required? | ExprVal? | Description |
name | Y | N | The name of the Java method context variable to create. |
property | N | N | The name of the context attribute to attach the value to. If not specified will be the same as name. |
type | N | N | The Java type of the object. If not specified defaults to org.ofbiz.entity.GenericValue. |