Hi,
We have many places in our JavaScript code where URLs are computed from
different fragments. The most common use case is appending query string
parameters to an existing URL:
window.docgeturl + '?xpage=xpart&vm=' + extraTemplate
This code works well in servlet mode but it's almost impossible to
integrate in portlet mode because portlet URLs are special
http://dev.xwiki.org/xwiki/bin/view/Drafts/PortletIntegration#HPortletURLs
. You can't add parameters to a portlet URL by simply appending them to
the query string.
There are two scenarios (for portlet mode):
(1) Either window.docgeturl is a portlet URL written on the server when
the page was rendered and in this case parameters appended to the query
string will be ignored
(2) or window.docgeturl is a servlet URL, but we have to rewrite on the
server the computed URL into a portlet URL -- impossible
What if we avoid computing URLs in JavaScript code and instead get the
URLs from HTML elements (e.g. anchors or forms)?
<a id="commentsResourceId" href="$doc.getURL('get',
'?xpage=xpart&vm=commentsinline.vm')"
class="hidden">Comments</a>
...
$(commentsResourceId).href
I'm interested to know if this would help others too.
Thanks,
Marius