Skip to main content
Kinetic Community

Bundle Helper

The Bundle Helper contains some useful methods for locating and working with directory paths when linking / including other files within the bundle. A developer an link / include other files relative to the bundle root directory, rather than relative to the current file in the directory structure.

Getting Started

Configuration

The bundle helper is automatically added as a request attribute when displaying any form, so there is no additional configuration necessary for this helper.

Usage

<%-- layout.jsp --%>
<link rel="icon" type="image/png" href="${bundle.location}/images/android-chrome-96x96.png" sizes="96x96">

Methods

getApiLocation()
getApiLocation(String apiVersion)

Returns the Space API route, relative to the web server.

bundle.getApiLocation()                  // /kinetic/acme/app/api/v1
bundle.getApiLocation("v1")              // /kinetic/acme/app/api/v1
${bundle.apiLocation}
${bundle.getApiLocation('v1')}

getKappLocation()
getKappLocation(String kappSlug)

Returns the Kapp display route, relative to the web server. Without the slug, the current Kapp is assumed, otherwise the specified Kapp is used.

bundle.getKappLocation()                 // /kinetic/acme/fulfillment
bundle.getKappLocation("approvals")      // /kinetic/acme/approvals
${bundle.kappLocation}
${bundle.getKappLocation('approvals')}

getKappPath()
getKappPath(String kappSlug)

Returns the Kapp path, relative to the web server application context. Without the slug, the current Kapp is assumed, otherwise the specified Kapp is used.

bundle.getKappPath()                     // /acme/catalog
bundle.getKappPath("approvals")          // /acme/approvals
${bundle.kappPath}
${bundle.getKappPath('approvals')}

getLogger()

Returns a logger that writes to the Kinetic application.log file.

bundle.getLogger()

The logger is most often used in other helpers to create tracedebuginfowarn, or error log messages (which can be accomplished by calling a method with the corresponding name).

<%! 
    public static class ExampleHelper {
        private HttpServletRequest request;
        private Bundle bundle;
        public BridgedResourceHelper(HttpServletRequest request) {

        }
        public String buildContent() {
            bundle.getLogger().debug("Calling ExampleHelper.buildContent()");
            return ...;
        }
    }
%>

getLocation()

Returns the route to the bundle, relative to the web server.

bundle.getLocation()                     // /kinetic/app/bundles/acme
${bundle.location}

getPath()

Returns the bundle path, relative to the web server application context.

bundle.getPath()                         // /app/bundles/acme
${bundle.path}

getSpaceLocation()

Returns the Space display route, relative to the web server.

bundle.getSpaceLocation()                // /kinetic/acme
${bundle.spaceLocation}

getSpacePath()

Returns the Space path, relative to the web server application context.

bundle.getSpacePath()                    // /acme
${bundle.spacePath}

Related