掲示板

How to use themeDisplay object as param in JSONWS ?

thumbnail
8年前 に Mario Aballe Rodriguez によって更新されました。

How to use themeDisplay object as param in JSONWS ?

Junior Member 投稿: 34 参加年月日: 10/01/20 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
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
8年前 に Mario Aballe Rodriguez によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 10/01/20 最新の投稿
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
8年前 に Juan Gonzalez によって更新されました。

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

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
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
8年前 に Mario Aballe Rodriguez によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 10/01/20 最新の投稿
Hi Juan = hola Juan
You have any examples the how to use INNER PARAMETERS ???? maybe the solucition is there.

Thank you!!!
thumbnail
8年前 に Juan Gonzalez によって更新されました。

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

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
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
8年前 に Mario Aballe Rodriguez によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 10/01/20 最新の投稿
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
7年前 に Krunal Kumar Patel によって更新されました。

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

New Member 投稿: 7 参加年月日: 12/07/27 最新の投稿
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
7年前 に Mario Aballe Rodriguez によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 10/01/20 最新の投稿
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.