Displays one of two possible outputs, depending on whether its input parameter is empty.
Class Name |
|
---|---|
Component |
|
Required Input Parameters
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.
Usage Notes
IsEmpty
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:
Data type | Considered empty if... |
---|---|
Collection |
|
object array |
|
Map |
|
Dictionary |
|
String |
|
Example
The following example displays the a user’s hobbies, using ForEach 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>