Implement the visualization

This step is a guide on how to implement different views in JSP using different tag libraries.

Before a taglib can be used it must be defined in both the web.xml and in the JSP using the taglib.

Example 10.6. Taglib, definitions in web.xml

          <taglib>
            <taglib-uri>http://kmr.nada.kth.se/scam/taglib/ScamTaglib/dc</taglib-uri>
            <taglib-location>/WEB-INF/tld/DCTaglib.tld</taglib-location>
          </taglib>
          <taglib>
            <taglib-uri>http://kmr.nada.kth.se/scam/taglib/ScamTaglib/dcq</taglib-uri>
            <taglib-location>/WEB-INF/tld/DCTERMSTaglib.tld</taglib-location>
          </taglib>
                
                

In a taglib directive the uri attribute must correspond to the value in the <taglib-uri> tag.

Example 10.7. Taglib, definition in JSP

 
            <%@ taglib prefix="dc"    uri="http://kmr.nada.kth.se/scam/taglib/ScamTaglib/dc" %>
            <%@ taglib prefix="dcq"   uri="http://kmr.nada.kth.se/scam/taglib/ScamTaglib/dcq" %>
                
                

A JSP may use an arbitrary name as an alias for a command-chain (outgoing transitions), as long as it is unique in the application. Document which alias that is used for which transition.

Example 10.8. Taglib, creating an event URL

                <c:url var="homeURL" value="${applicationURLsBean.path}">
                    <c:param name="cmd" value="open"/>
                    <c:param name="manifest" value="${req.remoteUser}"/>
                </c:url>
                
                

The example shows howto create an event URL that represents a request to open the portfolio that is associated with the current user. The context path is provided by the applicationURLsBean and the query string is built from the defined parameters.

Example 10.9. Taglib, applying an event URL

                <tr>
                    <td class="text">
                        <a href='<c:out value="${homeURL}"/>'>
                            <fmt:message key="btn.portfolio"/>
                        </a>
                    </td>
                <tr>
                
                

In this case is an anchor tag used as an UI to the event URL. An event URL can also be used as the action attribute value in a form tag. In that case must the parameters be provided in form.

An object that is made available with the Context object is also available in Java Standard Tag Library (JSTL) expression language (EL). See Example 10.2 on how to provide an attribute object. scamTaglib provides help on visualizing commonly used vocabularies and providing access to different types of properties.

Example 10.10. Taglib, single value property

                <scam:inModel subject="${modelBean.root}" var="inModel"/>
                
                

This example shows how the value of the scam:inModel property is accessed. The var attribute defines a reference to the value, the id attribute can used to define a referece to the tag. If the var and id attributes are undefined, the property value is written directly on the resulting page. By using the var or the id attributes the property value can be processed further by other tags.

Example 10.11. Taglib, processing a property value

                    <dcq:extent subject="${subject}" var="extent">
                        <scam:numberFormat number="${extent}" radix="kB"/> (<c:out value="${extent}"/> byte)
                    </dcq:extent>
                    
                
                    Result:
                    1,12 kB (1 151 byte)
                

A multi-valued property tag can define a delimiter token in the delimiter attribute. This token is inserted after each value, excluding the last value. This attribute should not be used if any of the id or var attributes are defined.

Example 10.12. Taglib, multi-value property

                  <dc:subject subject="${subject}" delimiter=", "/>
                
                
                    Result:
                    mars, water, ice
                

If the id attribute is defined, the value can be used for accessing the property tag itself. A property tag can in such case provide information about the set of values.

Example 10.13. Taglib, set operation

                <vCard:EMAIL subject="${anon}" var="email" id="emailID">
                    <% if(firstRun){ firstRun = false;%>&lt;<%}%>
                    <a href='mailto:<c:out value='${email}'/>'>
                        <c:out value="${email}"/>
                    </a>
                    <c:if test="${emailID.hasMore}">, </c:if>
                    <c:if test="${!emailID.hasMore}">&gt;</c:if>
                </vCard:EMAIL>