Message Boards

portlet:resourceURL parameters with Javascript

Manuel Baltieri, modified 3 Years ago.

portlet:resourceURL parameters with Javascript

New Member Posts: 7 Join Date: 4/21/20 Recent Posts

Hello,
how i can populate the "fileId" parameter value with the value passed when i call the function downloadFile?

function downloadFile(fileIdValue)
{
   location = '<portlet:resourceurl><portlet:param name="fileId" value="fileIdValue" /></portlet:resourceurl>';
}
thumbnail
Yogesh Sharma, modified 3 Years ago.

RE: portlet:resourceURL parameters with Javascript (Answer)

Junior Member Posts: 32 Join Date: 3/7/12 Recent Posts
fileIdValue is your request parameter?
If so, scriptlet can help in this.
Else if this will be javascript value only, you may need to have initial resource url available as js variable (say downloadResUrl) and append the parameter to that in javascript scope only.

function downloadFile(fileIdValue)
{
var downloadResUrl = '<portlet:resourceurl></portlet:resourceurl>';
location = Liferay.Util.addParams("fileId="+fileIdValue, downloadResUrl);
}

&nbsp;
Manuel Baltieri, modified 3 Years ago.

RE: portlet:resourceURL parameters with Javascript

New Member Posts: 7 Join Date: 4/21/20 Recent Posts

Tanks fot the support Yogesh Sharma.I've implemented it and now my code is more clean =)

This is my actual code now:

function downloadFile(fileIdValue)
{
	var downloadResUrl = '<portlet:resourceURL></portlet:resourceURL>';
	location = Liferay.Util.addParams("fileId="+fileIdValue, downloadResUrl);
	return false;
}