[MAGNOLIA-302] cms:ifEmpty tag is not working properly Created: 05/Mar/05  Updated: 17/Apr/05  Resolved: 17/Apr/05

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 2.01
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Andreas Weder Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

2.02 branch, java 1.4.2_06, any browser


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

It looks to me like the ifEmpty tag is not working properly in all situations.

I have an already existing page to which I added the following tags:

<cms:contentNodeIterator contentNodeCollectionName="centralLeftLinks">
<cms:adminOnly>
<div style="clear:both;">
<cms:editBar editLabel="Edit" moveLabel="" deleteLabel="Delete"/>
</div>
</cms:adminOnly>
<td class="aktuell_links"><cms:includeTemplate /></td>
</cms:contentNodeIterator>
<cms:ifEmpty contentNodeCollectionName="centralLeftLinks">
<cms:adminOnly><td>
<div style="clear:both;">
<cms:newBar contentNodeCollectionName="centralLeftLinks" paragraph="linksParagraph" newLabel="New links" />
</div>
</td></cms:adminOnly>
</cms:ifEmpty>

The intention of this is to only offer a newBar if no "linksParagraph" has already been instantiated. Using this version with the cms:ifEmpty tag works fine for a newly created page.

If I have an existing page however, which didn't contain any "centralLeftLinks" contentNode so far, the newBar never shows up. If I somehow manage to make the page contain the contentNode for at least once (i.e. with the code snippet below), the ifEmpty tag then works the way it's supposed to work.

If I replace the above cms:ifEmpty tag with the following inline java code, however, I get what I need:

<%
ContentNode collection = null;
Content actPage = Resource.getActivePage(request);
try

{ collection = actPage.getContentNode("centralLeftLinks"); }

catch (Exception e)

{ // Do nothing, if not found. }

if ((collection == null) ||
((collection != null) && (!collection.isHasChildren()))) {
%>

I've deleted the "work" directory of tomcat, and I've also tried to patch the ifEmpty code to work exactly like my inline code, but that doesn't help.



 Comments   
Comment by Fabrizio Giustina [ 17/Apr/05 ]

fixed in svn

Generated at Mon Feb 12 03:16:05 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.