Author: fpunt Date: 2010-08-04 10:08:11 +0200 (Wed, 04 Aug 2010) New Revision: 43042
Modified: CMSContainer/trunk/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/RelatedContentPortlet.java Log: [CMSC-1725] Modified: CMSContainer/trunk/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/RelatedContentPortlet.java =================================================================== --- CMSContainer/trunk/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/RelatedContentPortlet.java 2010-08-03 11:51:26 UTC (rev 43041) +++ CMSContainer/trunk/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/RelatedContentPortlet.java 2010-08-04 08:08:11 UTC (rev 43042) @@ -35,7 +35,8 @@ /** * This regex pattern is used to match the elementId from a renderURL. */ - private static final String RENDERURL_ELEMENTID_PATTERN = "_([0-9]+)"; + private static final String RENDERURL_ELEMENTID_WINDOW_REPLACE = "WINDOW"; + private static final String RENDERURL_ELEMENTID_PATTERN = RENDERURL_ELEMENTID_WINDOW_REPLACE+"_elementId/1_([0-9]+)"; @Override protected void saveParameters(ActionRequest request, String portletId) { @@ -97,7 +98,7 @@ protected String getRelatedElementId(RenderRequest request, String relatedPage, String relatedWindow) { String elementId = getElementIdFromContentURL(request); if (StringUtils.isEmpty(elementId)) { - elementId = getElementIdFromRenderURL(request); + elementId = getElementIdFromRenderURL(request, relatedWindow); if (StringUtils.isEmpty(elementId)) { if (StringUtils.isNotEmpty(relatedPage) && StringUtils.isNotEmpty(relatedWindow)) { elementId = getElementIdFromScreen(request, relatedPage, relatedWindow); @@ -131,9 +132,9 @@ return null; } - private String getElementIdFromRenderURL(RenderRequest req) { + private String getElementIdFromRenderURL(RenderRequest req, String relatedWindow) { String requestURL = getServletRequest(req).getRequestURL().toString(); - Pattern pattern = Pattern.compile(RENDERURL_ELEMENTID_PATTERN); + Pattern pattern = Pattern.compile(RENDERURL_ELEMENTID_PATTERN.replaceAll(RENDERURL_ELEMENTID_WINDOW_REPLACE, relatedWindow)); Matcher matcher = pattern.matcher(requestURL); String value = null; while (matcher.find() && matcher.groupCount() >= 1) { @@ -141,6 +142,7 @@ } return value; } + private HttpServletRequest getServletRequest(RenderRequest req) { return (HttpServletRequest) ((PortletRequestImpl) req).getRequest(); } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs