Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Habib Zare
serviceContext.getAssetTagNames() returns null
April 15, 2013 2:08 AM
Answer

Habib Zare

Rank: Junior Member

Posts: 58

Join Date: October 28, 2012

Recent Posts

I have created Book entity. i want to add tags and category for every book like BlogsEntry.

in the method of BlogsEntry`s service :

 1BlogsEntryLocalServiceImpl.addEntry(..., ServiceContext){
 2
 3.....
 4....
 5.....
 6
 7// Asset 
 8updateAsset( userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
 9
10....
11}


the serviceContext.getAssetTagNames() returns the string array of tags.

I have created the method addBook :

 1BookLocalServiceImpl.addBook(..., ServiceContext) {
 2.............
 3..........
 4//asset
 5   updateAsset(userId, book, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
 6
 7
 8return book;
 9}

in this method serviceContext.getAssetTagNames() returns null;

why?

in the action i do (like the BlogsEntry )
1ServiceContext serviceContext = ServiceContextFactory.getInstance(Book.class.getName(), actionRequest);
2// call the service method.



why i cannot get serviceContext.getAssetTagNames()?(or serviceContext.getAssetCategoryIds())
Habib Zare
RE: serviceContext.getAssetTagNames() returns null
April 15, 2013 6:31 AM
Answer

Habib Zare

Rank: Junior Member

Posts: 58

Join Date: October 28, 2012

Recent Posts

Hi,All. any idea?
Amos Fong
RE: serviceContext.getAssetTagNames() returns null
April 16, 2013 12:24 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1896

Join Date: October 7, 2008

Recent Posts

How did you add categories/tags in the JSP?

This is how blogs does it:
 1
 2    <liferay-ui:asset-categories-error />
 3
 4    <liferay-ui:asset-tags-error />
 5
 6    <aui:model-context bean="<%= entry %>" model="<%= BlogsEntry.class %>" />
 7...
 8                <aui:input name="categories" type="assetCategories" />
 9
10                <aui:input name="tags" type="assetTags" />
Habib Zare
RE: serviceContext.getAssetTagNames() returns null
April 23, 2013 6:12 AM
Answer

Habib Zare

Rank: Junior Member

Posts: 58

Join Date: October 28, 2012

Recent Posts

Thanks Amos Fong.

I did the same way.

I think the problem is in
ServiceContextFactory.getInstance(Book.class.getName(), actionRequest);


I solved my problem by doing:

1
2long[] assetCategoryIds = StringUtil.split(ParamUtil.getString(uploadRequest, "assetCategoryIds"), 0L);
3String[] assetTagNames = StringUtil.split(ParamUtil.getString(uploadRequest, "assetTagNames"));
4
5serviceContext.setAssetCategoryIds(assetCategoryIds);
6serviceContext.setAssetTagNames(assetTagNames);


I think this is not good way but it works.