Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Vishnu Khatri
Create Category
April 18, 2012 1:45 AM
Answer

Vishnu Khatri

Rank: New Member

Posts: 6

Join Date: February 24, 2012

Recent Posts

Hi Everyone;
I want to create a new category on a user's request at run time in a particular vocabulary which is already created(vocabulary)

for creating a category through liferay admin panel is not helpfull
Please help me with proper steps to create new category through source code and not through liferay admin panel

Thanks in advance;
Vishnu Khatri
Vitaliy Koshelenko
RE: Create Category
April 24, 2012 9:18 AM
Answer

Vitaliy Koshelenko

Rank: Regular Member

Posts: 174

Join Date: March 25, 2011

Recent Posts

Hi, Vishnu.

Check the EditCategoryAction source code, updateCategory method.
So, to add new category use the following code:

AssetCategoryServiceUtil.addCategory(
parentCategoryId, titleMap, descriptionMap, vocabularyId,
categoryProperties, serviceContext);
Gwowen Fu
RE: Create Category
April 24, 2012 11:49 AM
Answer

Gwowen Fu

Rank: Expert

Posts: 253

Join Date: December 27, 2010

Recent Posts

If you are running on local server then use

AssetCategoryLocalServiceUtil.addCategory(userId, parentCategoryId, titleMap, null, vocabularyId, null, serviceContext);
Vishnu Khatri
RE: Create Category
April 24, 2012 10:58 PM
Answer

Vishnu Khatri

Rank: New Member

Posts: 6

Join Date: February 24, 2012

Recent Posts

Hi everyone;

Thanks for your reply i have created a new category using createAssetCategory(long categoryId) of AssetCategoryLocalService and for this all we need to create a primary key which we can assign as a categoryId to this newly created AssetCategory


Thanks and regards;
Vishnu Khatri.