-
Bug
-
Resolution: Fixed
-
Neutral
-
1.0.2
-
None
-
-
Empty show more show less
-
Kromeriz 30
-
2
It fails with an NPE in SiteAwareRendererWrapper on line 84 where it tries to use the content.
It appears that optional areas are rendered without a content node. In AreaElement.java we have this code:
private boolean canRenderAreaScript() { if (!this.isAreaDefinitionEnabled) { // area script can be rendered only when area is enabled return false; } if (this.areaNode != null) { return true; } if (this.optional && this.getServer().isAdmin() && !MgnlContext.getAggregationState().isPreviewMode()) { // render script for optional areas when being in edit mode on author instance return true; } return false; }
So if areaNode is null and optional is true and we're in preview mode on an author instance then we go ahead and call the renderer without a content node. The template script is then rendered.
This works fine in JspRenderer and FreemarkerRenderer but in SiteAwareRendererWrapper throws an NPE.
Without a content node SiteAwareRendererWrapper can't get the current site, and can't decide if it's rendering a page (well it could look at the renderable definition id to see if it has pages/ in it but there's no point since it doesn't have a site to use anyway).
SiteAwareRendererWrapper should just skip template prototype merging altogether and proceed with rendering when content is null. Basically assuming that when content is null its an area so there's nothing to do anyway. With this change the fix would be a simple null check.