Forums de discussion
serviceContext.getAssetTagNames() returns null
Habib Zare, modifié il y a 11 années.
serviceContext.getAssetTagNames() returns null
Junior Member Publications: 58 Date d'inscription: 28/10/12 Publications récentes
I have created Book entity. i want to add tags and category for every book like BlogsEntry.
in the method of BlogsEntry`s service :
the serviceContext.getAssetTagNames() returns the string array of tags.
I have created the method addBook :
in this method serviceContext.getAssetTagNames() returns null;
why?
in the action i do (like the BlogsEntry )
why i cannot get serviceContext.getAssetTagNames()?(or serviceContext.getAssetCategoryIds())
in the method of BlogsEntry`s service :
BlogsEntryLocalServiceImpl.addEntry(..., ServiceContext){
.....
....
.....
// Asset
updateAsset( userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
....
}
the serviceContext.getAssetTagNames() returns the string array of tags.
I have created the method addBook :
BookLocalServiceImpl.addBook(..., ServiceContext) {
.............
..........
//asset
updateAsset(userId, book, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
return book;
}
in this method serviceContext.getAssetTagNames() returns null;
why?
in the action i do (like the BlogsEntry )
ServiceContext serviceContext = ServiceContextFactory.getInstance(Book.class.getName(), actionRequest);
// call the service method.
why i cannot get serviceContext.getAssetTagNames()?(or serviceContext.getAssetCategoryIds())
Habib Zare, modifié il y a 11 années.
RE: serviceContext.getAssetTagNames() returns null
Junior Member Publications: 58 Date d'inscription: 28/10/12 Publications récentes
Hi,All. any idea?
Amos Fong, modifié il y a 11 années.
RE: serviceContext.getAssetTagNames() returns null
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
How did you add categories/tags in the JSP?
This is how blogs does it:
This is how blogs does it:
<liferay-ui:asset-categories-error />
<liferay-ui:asset-tags-error />
<aui:model-context bean="<%= entry %>" model="<%= BlogsEntry.class %>" />
...
<aui:input name="categories" type="assetCategories" />
<aui:input name="tags" type="assetTags" />
Habib Zare, modifié il y a 11 années.
RE: serviceContext.getAssetTagNames() returns null
Junior Member Publications: 58 Date d'inscription: 28/10/12 Publications récentes
Thanks Amos Fong.
I did the same way.
I think the problem is in
I solved my problem by doing:
I think this is not good way but it works.
I did the same way.
I think the problem is in
ServiceContextFactory.getInstance(Book.class.getName(), actionRequest);
I solved my problem by doing:
long[] assetCategoryIds = StringUtil.split(ParamUtil.getString(uploadRequest, "assetCategoryIds"), 0L);
String[] assetTagNames = StringUtil.split(ParamUtil.getString(uploadRequest, "assetTagNames"));
serviceContext.setAssetCategoryIds(assetCategoryIds);
serviceContext.setAssetTagNames(assetTagNames);
I think this is not good way but it works.