Foros de discusión

How to use themeDisplay object as param in JSONWS ?

thumbnail
Mario Aballe Rodriguez, modificado hace 8 años.

How to use themeDisplay object as param in JSONWS ?

Junior Member Mensajes: 34 Fecha de incorporación: 20/01/10 Mensajes recientes
Hi i have this code:

Liferay.Service(
'/miportalliferay.journalarticle/get-article-content',
{
groupId: themeDisplay.getScopeGroupId(),
articleId: '36933',
languageId: themeDisplay.getLanguageId(),
themeDisplay: themeDisplay // javascript Liferay Object
},
function(obj) {
console.log(obj);
}
);


But throws java.lang.NullPointerException call this ws;
my question is: How to use themeDisplay object as param in JSONWS ???
thumbnail
David H Nebinger, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Not sure that's possible. Params that you define for your own web service need to either be primitives (or object wrappers) or objects which Liferay knows how to marshal from JSON format into the corresponding Java object.

When you check out the Liferay services (even for local services), they never use a front end object like ThemeDisplay as a parameter to services.

I'd recommend using the Liferay way to build your method, pass each of the necessary args as args, not an object wrapper. Kind of like how you did for the language id.
thumbnail
Mario Aballe Rodriguez, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Junior Member Mensajes: 34 Fecha de incorporación: 20/01/10 Mensajes recientes
Hi David, your idea is good.
My goal is to get the contents of a journalArticle but the content can be written in Volocity.
I have to ServiceBuilder services I need to call my aplication. I know that using:

String content = StringPool.BLANK;
JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay (themeDisplay.getScoprGroupId(), articleId,"","",themeDisplay);
content = articleDisplay.getContent();

reference articles:
Display web content in JSP Page
Programando contenidos en Liferay 6

In Java : themeDisplay.getScoprGroupId() = themeDisplay.getScopeGroupId() In JavaScript :
but how to create themeDisplay object with all values attributes same themeDisplay in JavaScript?

My question is, exists another way to get content of an article which uses velocity to build its content ??
Note:
My Portlet JSP : JavaScript, Angular Material, JQuery, ServiceBuilder (JSONWS(remote services)).
Thank you!
thumbnail
Juan Gonzalez, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Liferay Legend Mensajes: 3089 Fecha de incorporación: 28/10/08 Mensajes recientes
Hi Mario,

maybe you can try using the json tester page (/api/jsonws) and check the generated script so you can cop/paste.

Here you have some other resources:

https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/invoking-json-web-services.

Hope it helps...
thumbnail
Mario Aballe Rodriguez, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Junior Member Mensajes: 34 Fecha de incorporación: 20/01/10 Mensajes recientes
Hi Juan = hola Juan
You have any examples the how to use INNER PARAMETERS ???? maybe the solucition is there.

Thank you!!!
thumbnail
Juan Gonzalez, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Liferay Legend Mensajes: 3089 Fecha de incorporación: 28/10/08 Mensajes recientes
Search for some built-in Liferay service that requires themeDisplay, and using json ws tester page you can see how it's being done.
thumbnail
Mario Aballe Rodriguez, modificado hace 8 años.

RE: How to use themeDisplay object as param in JSONWS ?

Junior Member Mensajes: 34 Fecha de incorporación: 20/01/10 Mensajes recientes
im using api/jsonws:
/miportalliferay is the portal context

Liferay.Service(
 '/miportalliferay.journalarticle/get-article-content',
	{
	 groupId: themeDisplay.getScopeGroupId(),
	 articleId: '36933',
	 languageId: themeDisplay.getLanguageId(),
	 themeDisplay: themeDisplay
	},
	function(obj) {
		console.log(obj);
	}
);


VM147:11 java.lang.NullPointerException

But if themeDisplay is null:

Liferay.Service(
 '/miportalliferay.journalarticle/get-article-content',
	{
	 groupId: themeDisplay.getScopeGroupId(),
	 articleId: '36933',
	 languageId: themeDisplay.getLanguageId(),
	 themeDisplay: null 
	},
	function(obj) {
		console.log(obj);
	}
);

Return the content but not replaced the tokens (@cdn_host@,@root_path@) is logic because use use the atributes the themeDisplay by remplace the tokens.
Then depend on themeDisplay to replace the tokens, in others words i need the themeDisplay, but how to use the get-article-content method jsonws, any example?, another way??
thumbnail
Krunal Kumar Patel, modificado hace 7 años.

RE: How to use themeDisplay object as param in JSONWS ?

New Member Mensajes: 7 Fecha de incorporación: 27/07/12 Mensajes recientes
Hi Mario,

I have same problem that you faced. I also want to get journal article content using jsonws api.
Did you get any solution using jsonws api.?

Thanks,
Krunal Patel
thumbnail
Mario Aballe Rodriguez, modificado hace 7 años.

RE: How to use themeDisplay object as param in JSONWS ?

Junior Member Mensajes: 34 Fecha de incorporación: 20/01/10 Mensajes recientes
Hi Krunal

My apologies for the time to write. The answer is no.
But you can read this peapers because you can use call ajax in the portlet or you use this literature for crate a new idea:

display-web-content:
display web content in jsp page
To use Assets Tutorial in spanish language

call ajax in the portlet
http://www.opensource-techblog.com/2015/07/aui-ajax-in-liferay-portlet.html

http://liferayiseasy.blogspot.com/2015/03/ajax-call-in-spring-mvc-portlet.html

I hope this helps.