Hello,
I'm working on a project planning to use this portlet and found this problem and have a fix for it:
My setup includes:
- RedHat EL5
- Sun JDK 6
- Tomcat 6 standalone
- Liferay 4.3.0 portal
- PortletBridge Portlet 1.1.2 (comes with that liferay version)
I got the last version of the sources from CVS before starting to work on it, so all the comments regard to the very current version, if there were any diffs not yet in the 1.1.2
############################################
Symptoms:
URLs in included .css and .js are rewritten to /PortletBridgePortlet/#ID#/... instead of the /pbhs/ web-context. (I name it context here, not sure of the correct nomenclature)
Though when the url is changed to /phbs/ manually everything is working.
I tracked down the problem to the file PortletBridgeServlet.fetch - anony class: HttpClientCallback-doInHttpClient
in that in the .css and .js sections, the context part for the url is retrieved through getServletName():
.createBridgeFunctions(
memento,
perPortletMemento,
init-params
getServletName(),
url,
new PseudoRenderRequest(request.getContextPath()),
createRenderResponse(effectiveBridgeRequest));
whereas that function in my setup returns "PortletBridgePortlet" and not "pbhs".
#######################################################
Fix:
- Not sure if this is the best way to fix it, as I am not very familiar with the codebase:
(Parse the context where the id is parsed)
To PortletBridgeService interface add:
String getServletNameFromRequestURI(String contextPath, String requestUri);
To impl DefaultPortletBridgeService add:
public String getServletNameFromRequestURI(String contextPath, String requestUri) {
String path = contextPath.length() > 0 ? requestUri.substring(contextPath.length() - 1) : requestUri;
int secondIndexOfSlash = path.indexOf('/', 2);
if(secondIndexOfSlash >= 0 ) {
return path.substring( 1,secondIndexOfSlash );
}
return null;
}
In PortletBridgeServlet.doGet: add
final String servletName = portletBridgeService.getServletNameFromRequestURI(request
.getContextPath(), request.getRequestURI());
same function change the fetch call to:
fetch(request, response, bridgeRequest, memento, perPortletMemento, url, servletName);
The same change in the doPost method of that class.
###################################################
Would be glad to see a comment / commit on that change. I plan to submit some more fixes, hope the project is still somewhat active.
Best regards,
Thomas Klambauer
Logged In: YES
user_id=226508
Originator: NO
Ah, that's odd. Looking into it.