Details
-
Bug
-
Resolution: Fixed
-
Medium
-
2.8
-
None
Description
Using a web item that has no URL set causes the web item to inherit the previously rendered web item's URL.
Offending code:
#macro (renderItemLink $item $isCurrent) #set ($itemRenderedUrl = $item.link.getDisplayableUrl($req, $action.webInterfaceContext)) [...] <a #if ($item.link.id) id="$item.link.id"#end href="$itemRenderedUrl" #if ($itemClass) class="$itemClass"#end #if ($item.link.hasAccessKey()) accessKey="$item.link.getAccessKey($helper)"#end #if ($itemTooltip) title="$itemTooltip"#end>
If no URL is set on the web item, getDisplayableUrl returns null, but Velocity doesn't set $itemRenderedUrl as null. Furthermore, $itemRenderedUrl hangs around in the Velocity context – which has the effect that the previous web item's URL is outputted.
This would also be an issue for all the other variables.
Furthermore, we should wrap the href attribute on the <a> with an if statement, to allow web items to omit the URL.