Foren
Liferay Javascript API
Gwowen Fu, geändert vor 11 Jahren.
Liferay Javascript API
Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste Beiträge
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
Hitoshi Ozawa, geändert vor 11 Jahren.
RE: Liferay Javascript API
Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Can't you just .split() it?
Gwowen Fu, geändert vor 11 Jahren.
RE: Liferay Javascript API
Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste BeiträgeHitoshi 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 ) {
});
});
Hitoshi Ozawa, geändert vor 11 Jahren.
RE: Liferay Javascript API
Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
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.
Gwowen Fu, geändert vor 11 Jahren.
RE: Liferay Javascript API
Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste BeiträgeHitoshi 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.