掲示板
Liferay Javascript API
Hi,
I was able to use the following code to call my portlet's action, but I need to pass a string array. In my portlet the parameter states becomes one string "'IL', 'CA', 'WA'".
How could this be done?
Thanks!
Gwowen
I was able to use the following code to call my portlet's action, but I need to pass a string array. In my portlet the parameter states becomes one string "'IL', 'CA', 'WA'".
var stateArray = ['IL', 'CA', 'WA'];
var resourceURL= Liferay.PortletURL.createResourceURL();
resourceURL.setResourceId(methodName);
resourceURL.setPortletMode("view");
resourceURL.setWindowState("normal");
resourceURL.setParameter("states", stateArray);
resourceURL.setPortletId("fusion_WAR_learnplugin");
How could this be done?
Thanks!
Gwowen
11年前 に Hitoshi Ozawa によって更新されました。
RE: Liferay Javascript API
Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Can't you just .split() it?
Hitoshi Ozawa:
Can't you just .split() it?
Yes, I could do that if there is no way for that API to pass an array. Since my portlet handles the same request through jQuery post without any issue, I hope Liferay Javascript API can do the same.
Here is the jQuery post that passes array to my portlet:
$("#refreshTranscript").bind('click', function(event) {
event.preventDefault();
var categoryId = $('#categoryId').val();
var stateArray = [];
var courseIdArray = [59, 60, 61, 62, 10648, 6754, 6753, 10, 1936, 1794, 10392, 11660, 2913, 1541, 1950, 6861, 1869, 1977, 10602, 10159, 10725, 1794, 792, 10603, 10963, 10724, 1295, 10897];
var posting = $.ajax({
url: '${ refreshTranscript }',
type: "POST",
data: {'categoryId':categoryId, 'stateArray':stateArray, 'courseIdArray':courseIdArray},
dataType: "json",
traditional: true
});
posting.done(function( data ) {
});
});
11年前 に Hitoshi Ozawa によって更新されました。
RE: Liferay Javascript API
Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Sorry, I'm only using jQuery for my ajax calls. I don't want to get to dependent of using liferay's functions when it doesn't improve productivity. This is especially true because jQuery is very stable and I'm more sure that they won't change things too much so I'll be able to use it different versions of liferay. Liferay sometimes changes or drops the apis between versions and it'll need to modify the portlets to fit the new version if I used their apis.
Hitoshi Ozawa:
Sorry, I'm only using jQuery for my ajax calls. I don't want to get to dependent of using liferay's functions when it doesn't improve productivity. This is especially true because jQuery is very stable and I'm more sure that they won't change things too much so I'll be able to use it different versions of liferay. Liferay sometimes changes or drops the apis between versions and it'll need to modify the portlets to fit the new version if I used their apis.
Thanks for you reply. Hope someone has done this before can share the knowledge.