Foros de discusión

Calling external REST service(s) from within a portlet

Marvin Bleiberg, modificado hace 9 años.

Calling external REST service(s) from within a portlet

New Member Mensajes: 16 Fecha de incorporación: 4/06/12 Mensajes recientes
Can anyone share or point to a working example of a single portlet containing multiple buttons, each of which calls a (different) REST service (data is pushed/pulled to/from outside of Liferay, and will not be part of Liferay or Expando tables)? I've seen several discussions on related topics, but some are old threads, and very few point to a working example and/or include sample code.

thank you much for any guidance-
Marvin Bleiberg
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Calling external REST service(s) from within a portlet

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
Your button would invoke an action in the portlet which will invoke the remote rest service (i.e. using spring's RestTemplate class).

The challenge you have of course is that the results of the rest call should be displayed in the render phase (so if the page gets re-rendered the portlet content will show correctly w/o invoking the rest api again). Depending upon the size, you might use the portlet session to store the data in or you could do some other way (write to a temp file, store path in session, render can get the path read the file and display), ...
Marvin Bleiberg, modificado hace 9 años.

RE: Calling external REST service(s) from within a portlet

New Member Mensajes: 16 Fecha de incorporación: 4/06/12 Mensajes recientes
David-
Yes, that's what I need - for at least one of the API calls. (The others involve adding/deleting/modifying records, etc.) - all of it to external endpoints, and all API calls have defined responses in XML or JSON.

I'm not a coder - I can "create" and "deploy" a Liferay portlet in the Eclipse development environment, but can't code at all. Would this be something that a freelance java developer would have the knowledge to do? Or is there a level of Liferay knowledge that is required ('m afraid this portlet effort would be too small to be of any interest as a paid project to a firm that has a specialty in Liferay development). Can you suggest a way of finding an appropriately skilled resource to do this, on a freelance basis? (I trust I'm not violating any forum guidelines here - if I am, i apologize).

Thank you again, David - it is comforting to know you are always out there, and will quickly respond to my random newbie questions!

Marvin
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Calling external REST service(s) from within a portlet

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
I'm afraid to do it right it will need a java guy w/ some portlet experience (because of the lifecycle differences between a portlet and a servlet).

I wouldn't write off the Liferay firms. If it is for a non-profit or something, they might cut you some break (as long as you're using EE).

Alternatively there's lots of folks in the forum looking to build some liferay credibility, so you might try throwing a line out in the forums and see if you get any bites...
Marvin Bleiberg, modificado hace 9 años.

RE: Calling external REST service(s) from within a portlet

New Member Mensajes: 16 Fecha de incorporación: 4/06/12 Mensajes recientes
David -
My sense is that it would be much easier for me to build and deploy this kind of portlet (ie, minimal interaction with LR's internal tables) using ExtJS or Jquery. Do you have a strong position against that? (and why?)
Thank you, as always.
Marvin
thumbnail
David H Nebinger, modificado hace 9 años.

RE: Calling external REST service(s) from within a portlet

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
Nothing against it. If that's what you're familiar w/, then it shouldn't be a problem.