I'm testing richfaces components and portlet bridge on JetSpeed portal 2.2.1. I've created a portlet web application and almost everything seems to be working except for images. I have a portlet that has some richfaces components. When the portal page first renders, images for every richfaces component renders as expected. But when I do something that will trigger a re-render of some component that uses an image (for instance rich:tree) richfaces component renders normally but the images disappear.
I debugged the sources and figured out the problem is in org.jboss.portletbridge.AjaxPortletBridge class. For each image in the richfaces component (node icons for a tree for instance)
public void doFacesRequest(ResourceRequest request, ResourceResponse response)
method is invoked for the image. For the page's first render, the code forwards the image request to the dispatcher and images render normally. But for a re-render request triggerred by ajax, request has a parameter named Bridge.FACES_VIEW_ID_PARAMETER set to the portlet's view id. Since this parameter is not null, in this case bridge implementation assumes that the request for the image is a JSF request and tries to execute JSF lifecycle. Since the request is not actually a jsf render request, image is not rendered.
I fixed this behaviour by overriding AjaxPortletBridge class. Simply adding the condition (request.getResourceID() != null && !request.getResourceID().endsWith(".jsf")) to the if condition
if (null == request.getParameter(Bridge.FACES_VIEW_ID_PARAMETER) && null == request.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER))
prevents the bridge class to execute JSF lifecycle for image requests. When the condition becomes:
if ((null == request.getParameter(Bridge.FACES_VIEW_ID_PARAMETER) && null == request.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER)) || (request.getResourceID() != null && !request.getResourceID().endsWith(".jsf")))
Non-jsf resource requests (where ResourceID is bla_bla.gif) will be forwarded to the dispatcher.