This chapter describes about the Tag Library Utilities attributes:
The Calendar Tag Library consists of the following tags:
Emits the following: attr="BODY". The purpose of this tag is to aid in the construction of tag attributes, whose content is dynamically generated.
JSP
<utilsPrefix:link>
None.
This tag has the following attributes for which the Required value is “Yes”:
The fragment of text to emit prior to: ="BODY".
This tag provides the following bean properties for which the Access value is “n/a”:
n/a
<%-- example of attr tag usage --%> <util:link tagstart="<a" tagend=">"> <util:attr attr="href"> <util:url path="/DesktopServlet"></util:url> </util:attr> <util:attr attr="method">GET</util:attr> </util:link>GO HOME</a>
Will generate a link that includes session encoding, if needed. The "path" attribute is not subject to the rules of file lookup. The emitted markup may look something like: <a href="/DesktopServlet?sid=1a34" method="GET"/>
This tag makes the specified bean object available to the page. It is essentially the same as <jsp:useBean> except that it interoperates with the other bean tags in this tag library.
Empty
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate. The type attribute specifies the java class name of the object to use or create.
This tag has the following attributes for which the Required values are “No” and “Yes”:
Name of the bean to create.
Name of the bean to use.
Type of the bean; a java class name.
All the bean properties of the bean type created are available.
<%-- make a date available --%> <util:bean type="java.util.Date"> date = <util:get/> </util:bean> <%-- make a named date available --%> <util:bean id="date" type="java.util.Date"/> date = <util:get name="date"/> </util:bean>
The beans tag operates on a collection of the specified bean objects and iterates through that collection.
JSP
If the id attribute is specified then a collection of type and size is created. If the name attribute is specified then the collection is restored from the page context. The type attribute specifies the java class name of the object to create for the collection.
This tag has the following attributes for which the Required values are “Yes” and “No”:
Name of the bean collection to create.
Name of the bean collection to use.
A boolean that selects iteration. Default is "false", the collection will not iterate.
Type of the bean; a java class name.
Number of beans to create for the collection.
During iteration, specifies a name by which the current bean may be retrieved from the PageContext.
This tag provides the following bean properties for which the Type values are “Integer”, “Boolean” and the Access value is “Get/Set”:
Index of the current bean in the collection.
The number of iterations the collection should perform.
The zero based index from which to begin iteration.
The zero based index that denotes the item upon which iteration will terminate.
One-based start; suitable for presentation.
One-based end; suitable for presentation.
The size of the collection being paged.
Whether or not there are more items in the collection, beyond the current iterations.
Whether there are items in the collection preceding the current iterations.
<%-- create a list of 5 dates and set the seconds to the index --%> <util:beans id="dates" size="5" type="java.util.Date" iterate="true"> <util:get property="index" id="index"/> <util:bean> <util:set property="seconds" id="index"/> </util:bean> </util:beans> <%-- iterate through the dates collection --%> <util:beans name="dates" iterate="true"/> <util:bean> date = <util:get/> </util:bean> </util:beans>
This tag loads a message catalog specified by the resource attribute and makes it available to the page. A message catalog is a java.util.ResourceBundle object that is locale-specific. Also see the msg tag
JSP
The id attribute is used to make the message catalog available after the catalog end tag. The name attribute is used to make a previously create catalog available. This tag also makes a scripting variable, specified by the id attribute available. Use the getMsg(String key) method to get the message string.
This tag has the following attributes for which the Required value is “No”:
Name to save the catalog on the page context. This is also the name for the scripting variable.
Name to use to retrieve the catalog from the page context.
Resource name to locate the message catalog.
None.
<%-- get key 'message' from catalog 'sample' --%> <util:catalog resource="sample"> Message = <util:msg key="message"/> </util:catalog> <%-- get key from a named catalog --%> <util:catalog id="sample" resource="sample"/> ... Message = <util:msg name="sample" key="message"/> <%-- get key using scripting --%> <util:catalog id="sample" resource="sample"/> ... Message = <%= sample.getMsg("message") %>
This tag get a message specified by the key attribute from a message catalog and writes it to the page output. Also see the catalog tag.
Empty
If the name attribute is not specified then a parent catalog tag is used to locate the message catalog
The tag has the following attributes for which the Required values are “Yes” and “No”:
Name of the message catalog to use.
Key used to find the message in the catalog.
None.
<%-- get key 'message' from catalog 'sample' --%> <util:catalog resource="sample"> Message = <util:msg key="message"/> </util:catalog> <%-- get key from a named catalog --%> <util:catalog id="sample" resource="sample"/> ... Message = <util:msg name="sample" key="message"/>
The content tag sets the content type and charset of the JSP response. The charset is determined based upon the type of the device making the request, but the content type must be explicitly specified. The tag should appear prior to the generation of any output from the JSP.
None.
None.
The only attribute for content tag for which the Required value is Yes is:
Content type of the current JSP response.
None.
<%-- utility content --%> <util:content type="text/vnd.wap.wml"/>
This tag provides a reference to the state of the utility service for a given session. Use of this tag without a body verifies correct operation of the utility service.
JSP
None.
None.
The tag has the following properties for which the Type values are “Boolean”, “String”, and the Access value is “Get/Set”:
If "true", the url generated by the url tag is escaped according to the RFC2396 rules, otherwise, the url is not escaped. The default is "true".
If "true", the "&" separator in a query string parameter list constructed by the url tag is rendered as "&", otherwise, it is rendered as "&". The default is "true".
If set, multi-value request parameters, e.g. "names=john=mary", will be concatenated into a single value when referenced within a tag attribute using the "$(parmName)" nomenclature. The concatenated values will be separated by parmDelimiter.
<%-- utility context --%> <util:context> <util:set property="rfc2396" value="false"/> <util:set property="urlAmpEntity" value="false"/> </util:context>
This tag copies the specified property value from the source bean to the target bean.
Empty
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate.
This tag has the following attributes for which the Required value is “Yes” and “No”:
Name of the bean to use.
Name of the bean to copy from.
Name of the bean property to copy.
None.
<%-- copy 'time' property from d1 to d2 --%> <util:bean name="d1" type="java.util.Date"/> ... <util:bean name="d2" type="java.util.Date"/> ... <util:copy name="d2" property="time" source="d1"/>
This tag denotes a reference to an "edit" bean, a bean whose properties specify that certain editing be performed upon the enclosed body. The edit will be performed in the following order: String substitution, if any specified. String truncation, if any specified. Character entity escaping, if any specified. The edit bean may also be referenced by the get/set tags, resulting in the appropriate modifications to the values being get or set.
JSP
At least the id or name attribute must be specified, but not both.
This tag has the following attributes for which the Required value is “No”:
Specifies the id of the bean to create.
Specifies the name of the bean to use.
This tag provides the following bean properties for which the Type values are “Integer”, “Boolean” and Access value is “Get/Set”:
The number of characters to which to truncate the body.
A boolean that indicates whether or not to apply XML style character entity escaping to the body. The characters that will be escaped are: "<", ">", and "&".
If present, specifies that all instances of the indicated value be replaced by the value specified by the to attribute.
Specifies the string with which to replace all occurrences of the string specified by the from attribute. If to is not specified, it defaults to the null string.
<%-- truncate a mail subject line --%> <util:edit id="t1"> <util:set property="truncation" value="20"/> <util:set property="escape" value="true"/> </util:edit> ... <util:edit name="t1"> <mail:message> <mail:get property="subject"/> </mail:message> </util:edit> ... <%-- same thing, different way --%> ... <mail:get property="subject" edit ="t1"/>
This tag will perform a "forward" operation, similar to <jsp:forward>, but will construct the JSP resource name in one of two ways: The path attribute may specify a path to be used verbatim during the construction of the URL. Client data specific rewriting will not be applied to this value. The file and comp attributes may together specify a JSP resource that will be resolved using client data driven file lookup rules. Additionally, query string parameters may be appended to the URL by the inclusion of the appropriate parm tags within the body of the "forward" tag. With the exception of the parm tags, all body content is discarded. The parameters that are ultimately passed to the destination resource are the concatenation of those present in the original request, and those specified in the body of the forward tag.
JSP
Either path or, file and comp must be specified.
The tag has the following attributes for which the Required value is “No”:
The file for which to perform the lookup, and thence to forward.
The component that the target file belongs to, e.g., "mail", "cal", or "ab".
The path component of the URL. If path is specified, neither file nor comp should be specified.
n/a
<%-- forward tag example --%> <util:forward file="inbox.jsp" comp="mail"/> ... or possibly ... <util:forward file="inbox.jsp" comp="mail"> <util:parm name="parm1">abc</util:parm> </util:forward>
This tag retrieves the specified property and writes its value to the page output.
Empty
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate. The property attribute should be used to specify what to retrieve; if not specified then the bean object itself is retrieved as a string. The id attribute specifies the name to save the retrieved property as; useful for non-string properties. If the eval attribute is specified then the value of the attribute is evaluated and written to the page output; this replaces the bean processing described above.
This tag has the following attributes for which the Required value are “Yes” and “No”:
Name of the bean to use.
Name of the property to retrieve. If not specified then the bean itself is retrieve as a string.
Name to save the retrieved value as.
Attribute to evaluate and write to page output.
Specifies the edit bean that will be applied to the returned value.
None.
<%-- get the date time property from parent bean --%> <util:bean type="java.util.Date"> time = <util:get property="time"/> </util:bean> <%-- get the date time property from named bean --%> <util:bean id="date" type="java.util.Date"/> ... time = <util:get name="date" property="time"/> <%-- get the date bean itself as a string --%> <util:bean type="java.util.Date"> date = <util:get/> </util:bean> <%-- get a non-string bean property --%> <util:bean: type="Bean"> <util:get property="prop" id="handle"/> </util:bean> <%-- get an evaluated attribute --%> <util:catalog id="catalog" resource="catalog"/> <util:bean id="bean" type="java.util.Date"/> Msg = <util:get eval="$[catalog:msg]"/> Param = <util:get eval="$(requestparam)"/> Bean = <util:get eval="{bean}"/>
The if tag tests the specified property and includes the tag body if the property evaluates to true.
JSP
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate. The property specifies what to test. The value attribute specifies the string value to test the property; the id attribute specifies the bean object value to test the property. If neither value or id is specified then the test is true if the property value is non-null.
This tag has the following attributes for which the Required value are “Yes” and “No”:
Name of the bean to use.
Name of the property to test.
String value of the property to test.
Bean object value of the property to test.
None.
<%-- test if the date time == 0 on parent bean --%> <util:bean type="java.util.Date"> <util:if property="time" value="0"> ... date.time == 0 </util:if> </util:bean> <%-- test if the date time == 0 on named bean --%> <util:bean id="date" type="java.util.Date"/> ... <util:if name="date" property="time" value="0"> ... date.time == 0 </util:if> <%-- test if bean property is non-null --%> <util:bean type="Bean"> <util:if property="name"> ... Bean.name != null </util:if> </util:bean> <%-- test using two beans --%> <util:bean id="one" type="BeanOne"/> <util:bean id="two" type="BeanTwo"/> <util:if name="one" property="bean" id="two"> ... one.bean == two </util:if>
This tag tests the specified property and includes the tag body if the property evaluates to false. This is the opposite of the if tag.
JSP
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate. The property specifies what to test. The value attribute specifies the string value to test the property; the id attribute specifies the bean object value to test the property. If neither value or id is specified then the test is true if the property value is non-null.
This tag has the following attributes for which the Required value are “Yes” and “No”:
Name of the bean to use.
Name of the property to test.
String value of the property to test.
Bean object value of the property to test.
None.
<%-- test if the date time != 0 on parent bean --%> <util:bean type="java.util.Date"> <util:ifnot property="time" value="0"> ... date.time != 0 </util:ifnot> </util:bean> <%-- test if the date time != 0 on named bean --%> <util:bean id="date" type="java.util.Date"/> ... <util:ifnot name="date" property="time" value="0"> ... date.time != 0 </util:ifnot> <%-- test if bean property is null --%> <util:bean type="Bean"> <util:ifnot property="name"> ... Bean.name == null </util:ifnot> </util:bean> <%-- test using two beans --%> <util:bean id="one" type="BeanOne"/> <util:bean id="two" type="BeanTwo"/> <util:ifnot name="one" property="bean" id="two"> ... one.bean != two </util:ifnot>
This tag will perform an "include" operation, similar to <jsp:include>, but will construct the JSP resource name in one of two ways: The path attribute may specify a path to be used verbatim during the construction of the URL. Client data specific rewriting will not be applied to this value. The file and comp attributes may together specify a JSP resource that will be resolved using client data driven file lookup rules.
Empty
Either path or, file and comp must be specified.
This tag has the following attributes for which the Required value is “No”:
The file for which to perform the lookup, and thence to include.
The component that the target file belongs to, e.g., "mail", "cal", or "ab".
The path component of the URL. If path is specified, neither file nor comp should be specified.
n/a
<%-- include tag example --%> <util:include file="inbox-common.jsp" comp="mail"/>
Emits the following: tagstartBODYtagend The purpose of this tag is to aid in the construction of "link"-type tags, whose content is dynamically generated.
JSP
None.
This tag has the following attributes for which the Required value is “Yes”:
The fragment of text to emit prior to the BODY.
The fragment of text to emit following the BODY.
n/a
<%-- example of link tag usage --%> <util:link tagstart="<a" tagend=">"> <util:attr attr="href"> <util:url path="/DesktopServlet"></util:url> </util:attr> <util:attr attr="method">GET</util:attr> </util:link>GO HOME</a>
Will generate a link that includes session encoding, if needed. The "path" attribute is not subject to the rules of file lookup. The emitted markup may look something like: <a href="/DesktopServlet?sid=1a34" method="GET"/>
The list tag lists all properties of the specified bean to the page output. This tag is most useful for debugging; in particular the list format may not be suitable for markup and should be contained in <PRE> or equivalent tags.
Empty
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate.
This tag has the following attribute for which the Required value is “No:
Name of the bean to use.
None.
<%-- list the properties of a parent bean --%> <util:bean type="java.util.Date"> <util:list/> </util:bean> <%-- list the properties of a named bean --%> <util:bean id="date" type="java.util.Date"/> ... <util:list name="date"/>
The following: name=BODY will be added as a query string parameter to the URL being constructed by an either an enclosing url or forwardtag. The urlAmpEntity property of the utility context controls whether the query string parameter separator is generated as "&" or "&", when used from within an url tag.
JSP
<utilsPrefix:url> or <utilsPrefix:forward>
None.
This tag has the following attribute for which the Required value is “Yes”:
The name of the URL argument to be generated.
n/a
<%-- example of parm tag usage --%> <util:link tagstart="<a" tagend=">"> <util:attr attr="href"> <util:url path="/DesktopServlet"> <parm> name="op1">stuff</util:parm> </util:url> </util:attr> <util:attr attr="method">GET</util:attr> </util:link>GO HOME</a>
Will generate a link that includes session encoding, if needed. The "path" attribute is not subject to the rules of file lookup. The emitted markup may look something like: <a href="/DesktopServlet?sid=1a34&op1=stuff" method="GET"/>
The session tag provides access to session attributes.
Empty
If the id attribute is specified then the page attribute is restored using the session attribute. If the name attribute is specified then the session attribute is saved using the page attribute. If neither is specified then the session attribute is removed.
This tag has the following attributes for which the Required values are “Yes” and “No”:
Name of the page attribute to restore from the session attribute.
Name of the page attribute to save into the session attribute.
Name of the session attribute to operate on.
None.
<%-- create a date bean to use --%> <util:bean id="now" type="java.util.Date"/> <%-- save that bean into the session attributes --%> <util:session name="now" attribute="viewDay"> <%-- restore from the session attributes --%> <util:session id="now" attribute="viewDay"/> <%-- remove the bean from the session attributes --%> <util:session attribute="viewDay"/>
The set tag updates the specified property.
JSP
If the name attribute is not specified then uses a parent bean tag to locate the bean on which to operate. The property specifies what to update. The value attribute specifies the string value to update the property; the id attribute specifies the bean object value to update the property. Either value or id must be specified.
The tag has the following attributes for which the Required values are “Yes” and “No”:
Name of the bean to use.
Name of the property to update.
String value of the property to update.
Bean object value of the property to update.
Specifies the edit bean that will be applied to value prior to storage.
None.
<%-- set the date time property on parent bean --%> <util:bean type="java.util.Date"> <util:set property="time" value="0"/> </util:bean> <%-- set the date time property on named bean --%> <util:bean id="date" type="java.util.Date"/> ... <util:set name="date" property="time" value="0"/> <%-- set a bean onto another bean property --%> <util:bean id="one" type="BeanOne"/> <util:bean id="two" type="Beantwo"/> <util:set name="two" id="one" property="one"/>
The purpose of this tag is to aid in the construction of URLs. The path portion of the URL may be specified in one of two ways: The path attribute may specify a path to be used verbatim during the construction of the URL. Client data specific rewriting will not be applied to this value. The file and comp attributes may together specify a JSP resource that will be resolved using context sensitive resource lookup rules. The servlet context path will be prepended to the resulting URL. Additionally, query string parameters may be appended to the URL by the inclusion of the appropriate parm tags within the body of the "url" tag. With the exception of the parm tags, all body content is discarded.
JSP
<utilsPrefix:attr>
Either path or, file and comp must be specified.
This tag has the following attributes for which the Required value is “No”:
The file for which to generate a URL reference. If file is specified, comp should be specified and path should not be specified.
The component that the target file belongs to, e.g., "mail", "cal", or "ab".
The path component of the URL. If path is specified, neither file nor comp should be specified.
A boolean that indicates whether or not the session id should ever be included in the generated URI.
n/a
<%-- example of url tag usage, with "path" attribute --%> <util:link tagstart="<a" tagend=">"> <util:attr attr="href"> <util:url path="/portal/jsp/default/launchMail.jsp"></util:url> </util:attr> <util:attr attr="method">GET</util:attr> </util:link>GO HOME</a>
Will generate a link that includes session encoding, if needed. The "path" attribute is not subject to the rules of resource lookup. The emitted markup may look something like:<a href="/portal/jsp/launchMail.jsp?sid=1a34" method="GET"/>. Another example...
<%-- example of url tag usage, with "file" and "comp" attributes --%> <util:link tagstart="<a" tagend=">"> <util:attr attr="href"> <util:url file="inbox.jsp" comp="mail"></util:url> </util:attr> <util:attr attr="method">GET</util:attr> </util:link>GO HOME</a>
Will generate a link that has been resolved to the correct path for the client that has requested the page. The session encoding is added as needed. The emitted markup may look something like: <a href="/portal/jsp/default/mail/wml/inbox.jsp?sid=1a34" method="GET"/>