Orion Util Taglibrary

Deployment

1. Download the Util Taglib here.

2. Put the Util Taglib in your web applications WEB-INF/lib directory.

3. Reference the Util Taglib in your web applications configuration file (web.xml) like this:

    <taglib>
      <taglib-uri>utiltags</taglib-uri>
      <taglib-location>/WEB-INF/lib/utiltags.jar</taglib-location>
    </taglib>

4. In your JSP, reference the taglib like this:

    <%@ taglib uri="utiltags" prefix="util" %>

Overview

This tag-library contains general utility actions such as iterating constructs and similar. It is free to use and redistribute.

<util:displayCurrency amount="<%=Double%>" { locale="<%=Locale%>" } />

Formats a given amount as currency for a given Locale. If Locale is not specified, the Locale found in the request will be used. If Locale is not found in the request, the system default Locale will be used.

    amount - the amount to format
    locale - a optional Locale
    body - empty

Example usage:

    <util:displayCurrency amount="<%=account.getBalance()%>" locale="<%=account.getLocale()%>" />

<util:displayDate date="<%=Date%>" { locale="<%=Locale%>" } />

Formats a given date for a given Locale. If Locale is not specified, the system default Locale will be used.

    date - the date to format
    locale - a optional Locale
    body - empty

Example usage:

    <util:displayDate date="<%=account.getDate()%>" locale="<%=account.getLocale()%>" />

<util:displayNumber number="<%=Double%>" { locale="<%=Locale%>" } { format="<%=Format%>" } />

Formats a given number for a given Locale and Format. If Locale is not specified, the system default Locale will be used.

    number - the number to format
    locale - a optional Locale
    format - a optional Format
    body - empty

Example usage:

    <util:displayNumber number="<%=shoe.getSize()%>" />

<util:ifInRole role="<%=String%>" { include="<%=Boolean%>" } >
... JSP ...
</util:ifInRole>

Includes the body if the user is in the specified role.

    role - the Role to check if user is in
    include - include - if the body should be included if the user is in the role or not
    body - content to be included if the evaluation is true

Example usage:

    <util:ifInRole role="users" include="true">
      Logged in as <%=request.getRemoteUser()%><br>
      <form action="logout.jsp">
      <input type="submit" value="Log out"><br>
      </form>
    </util:ifInRole>
    <util:ifInRole role="users" include="false">
      <form method="POST">
      Username: <input name="j_username" type="text"><br>
      Password: <input name="j_password" type="password"><br>
      <input type="submit" value="Log in">
      </form>
    </util:ifInRole>

<util:iterate id="String" type="String" collection="<%=Collection%>" {max="<%=Integer%>"} >
... JSP ...
</util:iterate>

Iterates over the finder results from a home

    id - the variable to use for referencing the bean. Accessable inside the Tag
    type - the class of the bean
    collection - a collection of beans of the given type
    max - a optional maximum number of beans to iterate
    body - evaluated once for every bean in the collection

Example usage:

    <util:iterate id="contact" type="com.acme.connections.Contact" collection="<%=company.getContacts()%>" >
      <jsp:getProperty name="contact" property="name"/>
    </util:iterate>

<util:lastModified { locale="<%=Locale%>" } />

Displays the date the current file was last modified using a given Locale. If Locale is not specified, the Locale found in the request will be used. If Locale is not found in the request, the system default Locale will be used.

    locale - a optional Locale

Example usage:

    <util:lastModified/>

<util:sendMail { from="<%=String%>" } { to="<%=String%>" } { cc="<%=String%>" } { bcc="<%=String%>" } { subject="<%=String%>" } { mimeType="<%=String%>" } { session="<%=String%>" } >
... JSP ...
</util:sendMail>

Sends a mail using the given Mail Session. If no Session is given, the default Session is used.

    from - a optional sender
    to - optional TO recipient. Multiple recipients should be divided by ','
    cc - optional CC recipient. Multiple recipients should be divided by ','
    bcc - optional BCC recipient. Multiple recipients should be divided by ','
    subject - a optional subject
    session - a optional Mail Session JNDI name. If none is specified, the default Mail Session will be used
    body - the content of the mail

Example usage:

    <util:sendMail session="mailSession" from="foobar@acme.com" to="foobar@acme.com" subject="This is a mail">
      Hello there!
      This file was last updated <util:lastModified/>.
    </util:sendMail>

Suggestions can be sent to info@orionserver.com.