• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

logic:empty tag question

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my code:

<logic:notEmpty name="chDentalPlanForm" property="chDentalPlan">
<logic:iterate id="idental" name="chDentalPlanForm" property="chDentalPlan"
indexId="index">
<table cellpadding="5" cellspacing="1" width="100%" border="1">
<!-- display the dental plan details
</table>
</logic:iterate>
</logic:notEmpty>

<logic:empty name="chDentalPlanForm" property="chDentalPlan">
<p>No Details available </p>
</logic:empty>

The property chDentalPlan is an array. When the array is not empty, the <logic:notEmpty> tag displays all the values correctly. If the array is empty, the "No details Available" message is not displayed. I checked to see if the array is empty using the code:
if (chDentalPlan.length = 0) { }
it is empty. The message gets displayed.

Why does the <logic:empty> not work? Am I doing something wrong? Help!
Note: I tried <logic resent> around the <logic:empty> also. Did not work.

thanks
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure that the object you are checking it's a Collection, since I don't think it will work with Arrays like String[].

Try using Arraylist instead.
 
Sumithab Baskaran
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed the array to an ArrayList. now, the <logic:empty> dipslays the correct message, but the <logic:notEmpty> also displays the message. The "No Details available" message is always present regardless of the ArrayList being empty or not.
Any suggesstions?
 
Sumithab Baskaran
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, it was my mistake. I had the name and the property attributes all mixed up.
Thanks for the tip. It works!
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic