dsp:test takes an object input and produces an object named by the var-specified EL variable. Other tags can query the object to find out information about the original input object, such as its size (empty, null, or number of items).

Attributes

TagVariable:varorid(Required)

You must define an EL variable or scripting variable:

Attribute

Description

var

Names an EL variable. When you use var , you can set the scope attribute to page, request, session, and application, to specify the variable’s accessibility to other resources.

id

Names a scripting variable, which scriptlets and expressions can access at runtime.

VariableScope:scope

The scope attribute determines what resources can access the named EL variable. Options include: page, request, session, or application. Omitting this attribute causes the default, page, to be used.

ObjectInput:value(Required)

The value attribute holds a Collection, an array, or a Map that is passed to the object referenced by the EL variable.

Properties

nullValue

The nullValue property evaluates whether the object held by the value attribute has a value of 0. A call to isNull returns true when the contents are zero and false under any other circumstances.

array

The array property evaluates whether the object held by the value attribute is an array. A call to isArray returns true when the item is an array and false when it is not.

collection

The collection property evaluates whether the object held by the value attribute is a Collection. A call to isCollection returns true when the item is a Collection and false when it is not.

arrayOrCollection

The arrayOrCollection property evaluates whether the object held by the value attribute is an array or a Collection. A call to isArrayOrCollection returns true when the item is an array or Collection and false when it is not either data type.

size

The size property evaluates the size of the object held by the value attribute. A call to isSize returns the following:

emptyValue

The emptyValue property evaluates whether the object held by the value attribute has a value. A call to isEmpty returns the following:

valueClass

The valueClass property identifies the class of the object identified by the value attribute. When the value attribute is set to null, the valueClass returns null.

hashcode

The hashcode property renders the hash code associated with the object identified in the value attribute. A call to isHashCode when no hash code exists or the hash code is 0 returns null.

Example

<dsp:tomap bean="Articles.current" var="currentArticles"/>
<dsp:test var="objectSize" value="${currentArticles}"/>
    Total article count for this week should be 10. We have
    <c:out value="${objectSize.size}"/> articles.

In this example, the current property of the Articles component is passed through the dsp:test tag. The object referenced by the EL variable objectSize holds information about Articles.current and so a call to its size property returns the size of the current array.

 
loading table of contents...