Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Gwowen Fu
Liferay Javascript API
25 marzo 2013 14.38
Risposta

Gwowen Fu

Punteggio: Expert

Messaggi: 315

Data di Iscrizione: 27 dicembre 2010

Messaggi recenti

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'".

 1   
 2var stateArray = ['IL', 'CA', 'WA'];
 3
 4var resourceURL= Liferay.PortletURL.createResourceURL();
 5resourceURL.setResourceId(methodName);
 6resourceURL.setPortletMode("view");
 7resourceURL.setWindowState("normal");
 8resourceURL.setParameter("states", stateArray);
 9resourceURL.setPortletId("fusion_WAR_learnplugin");


How could this be done?

Thanks!
Gwowen
Hitoshi Ozawa
RE: Liferay Javascript API
25 marzo 2013 15.32
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

Can't you just .split() it?
Gwowen Fu
RE: Liferay Javascript API
26 marzo 2013 7.04
Risposta

Gwowen Fu

Punteggio: Expert

Messaggi: 315

Data di Iscrizione: 27 dicembre 2010

Messaggi recenti

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:

 1
 2    $("#refreshTranscript").bind('click', function(event) {
 3        event.preventDefault();
 4        var categoryId = $('#categoryId').val();
 5        var stateArray = [];
 6        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];
 7   
 8        var posting = $.ajax({
 9          url: '${ refreshTranscript }',
10          type: "POST",
11          data: {'categoryId':categoryId, 'stateArray':stateArray, 'courseIdArray':courseIdArray},
12          dataType: "json",
13          traditional: true
14        });
15       
16        posting.done(function( data ) {
17        });       
18    });
Hitoshi Ozawa
RE: Liferay Javascript API
26 marzo 2013 14.32
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
RE: Liferay Javascript API
29 marzo 2013 12.08
Risposta

Gwowen Fu

Punteggio: Expert

Messaggi: 315

Data di Iscrizione: 27 dicembre 2010

Messaggi recenti

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.