I have a JSR 168 Portlet deployed in IBM Portal Server that has a jsp with the following code...
<a href="
<portlet:renderURL>
<portlet:param name="itemNumber" value="<%=sessionBean.getItems()[i].getItemNumber()%>"/>
</portlet:renderURL>"><%=sessionBean.getItems()[i].getItemNumber()%>
</a>
I am now trying to move this code from my jsp into my jquery javascript but I don't think placing portlet:renderURL will give me the right result. I tried that and it left me with that custom tag as plain text in the source.
How can I get the value of portlet:renderURL variable into my javascript? . Or perhaps the better question is what is the correct way to pass a request parameter from javascript to the portletRequest object.
--Update--
Well here is an update on what I was able to achieve. I figured out today that I could do the following in my jsp...
<script type="text/javascript">
$().ready(function() {
var params = ({
portletUrl : '<%= renderResponse.createRenderURL() %>'
});
init(params);
});
And then in my jquery externalised file I could do...
var portletUrl = null;
$()ready(function(){
var myUrl = '<a href="'+portletUrl + "?itemNumber=" + data+'">' + data + '</a>';
}
function init(params) {
portletUrl = params.portletUrl;
}
It seems to work but I can't help thinking this is not the recommended method. Especially because to get the parameter I need to cast the portlet request to a http request.
thanks
Portlet tags can be rendered in jsp only. So,I feel you can assign the rendered the url with parameter values to a global javascript variable and use it across.