留言板

ModelListener JournalArticle problem onBeforeRemove

thumbnail
Borja Blázquez,修改在7 年前。

ModelListener JournalArticle problem onBeforeRemove

Junior Member 帖子: 30 加入日期: 13-10-7 最近的帖子
Hi,
i am trying to get the asset categories of a journalArticle which i want to remove. I have created a model Listener for JournalArticle and override the onBeforeRemove() method.

The problem is that when i try to get the asset categories, I need the entry of the journal article, but the call to the method is always returning null.

AssetEntry journalEntry = AssetEntryLocalServiceUtil.fetchEntry(JournalArticle.class.getName(),model.getResourcePrimKey());
AssetEntry journalEntry = AssetEntryLocalServiceUtil.getEntry(JournalArticle.class.getName(), model.getResourcePrimKey());

I think that before entering on this method, something is happening with the entry object so i can not get the entry for the current journal.

I have changed the overriden method to onBeforeUpdate (for example) and I do not get the error, i got the entry successfully.

Any idea of how to retrieve the asset categories before removing a journal article ?

thanks in advanced!
thumbnail
David H Nebinger,修改在7 年前。

RE: ModelListener JournalArticle problem onBeforeRemove

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
You have to check the sequencing on the delete operations. I'm guessing that the entry is being deleted before the journal article is being deleted, hence the null result in your model listener.







Come meet me at the LSNA!