Skip to main content
Kinetic Community

Bundle Tag Library

The Kinetic Bundle tag library is intended to be used in bundles to simplify JSP pages and make them easier to understand.

Getting Started

Configuration

The bundle tag library can be declared with the following taglib directive:

<%-- bundle/initialization.jspf --%>
<%@taglib prefix="bundle" uri="http://kineticdata.com/taglibs/bundle" %>

Usage

<%-- form.jsp --%>
...
<bundle:yield/>
...

Tags

The following tags are provided in the bundle tag library:

<bundle:layout>

Renders the layout file specified by the page attribute if provided, or the default bundle layout located at{bundle}/common/layout.jsp if not provided.

Attributes

  • page (optional) location of the layout page if provided, otherwise the bundle default layout will be used.

<bundle:log>

Creates tracedebuginfowarn, or error log message in the Kinetic application.log file.

Attributes

  • level (optional) tracedebuginfowarn, or error; defaults to debug if not specified.
  • message (optional) If specified, the message that will be logged. If not specified, the body of the bundle:log tag will be used.

Example

<bundle:log message="Test message: ${space.name}"/>
<bundle:log level="trace" message="Test message: ${space.name}"/>
<bundle:log level="debug" message="Test message: ${space.name}"/>
<bundle:log level="info" message="Test message: ${space.name}"/>
<bundle:log level="warn" message="Test message: ${space.name}"/>
<bundle:log level="error" message="Test message: ${space.name}"/>

<bundle:log level="info">
    Space: ${space.name}
    Kapp: ${kapp.name}
</bundle:log>

<bundle:request>

Used for making server-side HTTP requests. It works similar to <c:import>, but will use the session of the original request for any non-absolute url requests. This can be helpful in bundles because using <c:import> shares the same request scope, which can cause variable collisions.

The <bundle:request> tag is most often used when one Kapp calls a bundle API for another Kapp (for example, a catalog Kapp wants to embed and format a list obtained from an Alerts and Outages Kapp).

Attributes

  • method getpatchpostput, or delete
  • url An absolute (in which case a new session will be used) or relative (in which case the current session will be used) url
  • scope (optional) The scope that the variable is set into: pagerequestsession; defaults to page
  • var (optional) The name of the variable to set the result content into. If this is not set the content is output to the page.

Child Tags

  • bundle:requestBody If specified, this will set the body of the request.
  • bundle:requestHeader If specified, these will add additional headers to the request.
  • bundle:requestParam If specified, these will add additional parameters to the request.

Example

<%-- Absolute GET request --%>
<bundle:request method="GET" url="http://api.acme.com/v1/records/1101"/>

<%-- Relative GET request --%>
<bundle:request method="GET" url="${space.location}/alerts?page=api"/>

<%-- Relative GET request setting a variable with parameters--%>
<bundle:request method="GET" url="${space.location}/alerts" var="foo">
    <bundle:requestParam name="page" value="api"/>
</bundle:request>

<%-- Relative POST of application/x-www-form-urlencoded HTML form content --%>
<bundle:request method="POST" url="${space.location}/alerts?page=api">
    <bundle:requestParam name="Date" value="2016-01-01T09:00:00Z"/>
    <bundle:requestParam name="Description" value="Simple description."/>
</bundle:request>

<%-- Relative POST of application/json content --%> 
<bundle:request method="POST" url="${space.location}/alerts?page=api">
    <bundle:requestHeader name="Content-Type" value="application/json"/>
    <bundle:requestBody>
        <json:object>
            <json:property name="Date" value="2016-01-01T09:00:00Z"/>            
            <json:property name="Description" value="Simple description."/>
        </json:object>
    </bundle:requestBody>
</bundle:request>

<bundle:variable>

Defines content that will be rendered by the <bundle:yield> tag that matches the variable name assigned to this tag.

Attributes

  • name (required) name to use for the content defined in this tag. Will be rendered by the <bundle:yield> tag with the same name attribute.

<bundle:yield>

Renders the content defined in the <bundle:variable> tag that matches the variable name assigned to this tag if provided, or will render the body content defined in the <bundle:layout> tag.

Attributes

  • name (optional) if provided, renders the content defined in the body of the corresponding <bundle:variable> tag. Otherwise, renders the body content defined the parent <bundle:layout> tag.

<bundle:scriptpack>

Defines a set of javascript files that will be concatenated and minified, and added to the page as a single file. If the debugjsparameter is passed on the URL, each file will be added individually instead of concatenated, and the javascript files will be inserted as-is, without being minified.

Attributes

  • minify (optional) if false, skips the minification process
  • prefix (optional) affixes a prefix to the generated pack file for easier identification

Individual javascript files can be included in the pack using a <bundle:script> tag for each file.

Example

<bundle:scriptpack prefix="bundle">
    <bundle:script src="${bundle.path}/js/file1.js"/>
    <bundle:script src="${bundle.path}/js/file2.js"/>
</bundle:scriptpack>

<bundle:script>

Used within a <bundle:scriptpack> tag. This tag adds a javascript file to the set of javascript files that will be concatenated and minified as a single file.

Attributes

  • src (required) the path (relative to the web application context) to the javascript file

Example

<bundle:script src="${bundle.path}/js/bundle.js"/>

<bundle:stylepack>

Defines a set of stylesheet files that will be concatenated and minified, and added to the page as a single file. If the debugjsparameter is passed on the URL, each file will be added individually instead of concatenated, and the stylesheet files will be inserted as-is, without being minified.

Attributes

  • media (optional) specifies what media/device the target resource is optimized for
  • minify (optional) if false, skips the minification process
  • prefix (optional) affixes a prefix to the generated pack file for easier identification

Individual stylesheet files can be included in the pack using a <bundle:style> tag for each file.

Example

<bundle:stylepack media="screen" prefix="bundle">
    <bundle:style src="${bundle.path}/css/file1.css"/>
    <bundle:style src="${bundle.path}/css/file2.css"/>
</bundle:stylepack>

<bundle:style>

Used within a <bundle:stylepack> tag. This tag adds a stylesheet file to the set of stylesheet files that will be concatenated and minified as a single file.

Attributes

  • src (required) the path (relative to the web application context) to the javascript file

Example

<bundle:style src="${bundle.path}/css/bundle.css"/>

Related