-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: bridge-impl-3.0.0, bridge-impl-4.0.0
-
Fix Version/s: bridge-impl-3.1.0, bridge-impl-4.1.0
-
Component/s: Liferay Faces Bridge Impl / Demos / Tests
-
Labels:None
In com.liferay.faces.bridge.renderkit.html_basic.internal.BodyRendererBridgeImpl, there is a possible bug when head component is missing from the portlet the body renderer throws NullPointerException because attribute HEAD_RESOURCES_TO_RENDER_IN_BODY is never set and is null.
Usage for no head portlet view is when you want portlet included in theme via theme.runtime and you include its resources in themes head, thus you do not want those resources to be loaded in portlet itself. (I haven't found better way to do it)
In portal-impl-3.0.0 (link) it looks like it can be fixed with just a simple nullcheck around the for each loop between lines 115-127.
There is possible workaround with SystemEventListener just set it to default empty list. Check code below.
public class NoHeadFixerPhaseListener implements SystemEventListener { private static final String HEAD_RESOURCES_TO_RENDER_IN_BODY = "headResourcesToRenderInBody"; @Override public void processEvent(SystemEvent event) throws AbortProcessingException { Map<Object, Object> facesContextAttribtues = FacesContext.getCurrentInstance().getAttributes(); if (facesContextAttribtues.get(HEAD_RESOURCES_TO_RENDER_IN_BODY) == null) { facesContextAttribtues.put(HEAD_RESOURCES_TO_RENDER_IN_BODY, Collections.emptyList()); } } @Override public boolean isListenerForSource(Object source) { return true; //depends on your use, for our use there was only one registred portlet so I just left it to true since it is called for one UIViewRoot } } and in faces-config.xml add <application> <system-event-listener> <system-event-listener-class>cz.vrk.pi.ou.NoHeadFixerPhaseListener</system-event-listener-class> <system-event-class>javax.faces.event.PostAddToViewEvent</system-event-class> <source-class>javax.faces.component.UIViewRoot</source-class> </system-event-listener> </application>