ClassName |
|
---|---|
Component |
|
The IsEmpty
servlet bean conditionally renders one of its open parameters based on the value of its value
input parameter. If value
is null or if the object is empty, then the output parameter true is rendered. Otherwise, the output parameter false
is rendered.
The meaning of empty depends on the data type of the value parameter:
if the value is a Collection, and
Collection.isEmpty
returns trueif the value is an object array, and
Object [].length
== 0if the value is a Map, and
Map.isEmpty
returns trueif the value is a Dictionary, and
Map.isEmpty
returns trueif the value is a String, and
String.equals("")
returns true
Input Parameter
value
The value to test. The value
parameter is tested to determine if it is empty, and the result of this test determines the name of the open parameter to render. For example, if the value
parameter is empty, then IsEmpty
renders the value of its true
open parameter.
Open Parameters
true
The value to render if the value
parameter is empty.
false
The value to render if the value
parameter is not empty.
Example
This example displays the a user’s hobbies, using the ForEach
servlet bean to render them. If a user identifies no hobbies, a message displays:
<dsp:droplet name="IsEmpty"> <dsp:param name="value" bean="MyProfile.hobbies"/> <dsp:oparam name="false"> Your hobbies are: <dsp:droplet name="ForEach"> <dsp:param name="array" bean="MyProfile.hobbies"/> <dsp:oparam name="output"> <dsp:valueof param="element"/> </dsp:oparam> </dsp:droplet> </dsp:oparam> <dsp:oparam name="true"> All work and no play makes Jack a dull boy. </dsp:oparam> </dsp:droplet>