English 中文(简体)
生命线。 《日刊》
原标题:Liferay. Modify JournalArticle from ModelListener
  • 时间:2012-01-12 11:32:03
  •  标签:
  • liferay

我试图修改《日刊》中的条款资产(根据《公约》第4条界定父母的类别)。 我得以执行《日刊》第1条示范生计。 在方法<onAfterUpdate()中,我有JournalArticle Local ServicesUtil.updateAsset()。

在记录中,一切都是罚款。 我需要的是参数上的分类,但在我下一次开放的文章编辑时,它没有出现在第3条所列类别中。

能否避免模型的变化,使之脱离模型,还是仅仅用于监测,我可以不改变这个听众的模式?

法典(缩略本):

package mypackage;

// imports

public class JournalArticleListener implements ModelListener {

    private void updateCategories(JournalArticle article) {
        try {
            long[] categoriesArray = getCategories(article);  // this works fine
            String[] tagsArray = getTags(article); // this also works fine

            JournalArticleLocalServiceUtil.updateAsset(article.getUserId(), article, categoriesArray, tagsArray);
        } catch (PortalException ex) {
            // logger
        } catch (SystemException ex) {
            // logger
        }
    }

    @Override
    public void onBeforeUpdate(Object model) throws ModelListenerException {
        updateCategories((JournalArticle)model);
    }

    // other abstract method implemented without any code inside
}

页: 1 我

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.0.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd">

<hook>
    <model-listener>
        <model-listener-class>mypackage.JournalArticleListener</model-listener-class>
        <model-name>com.liferay.portlet.journal.model.JournalArticle</model-name>
    </model-listener>
</hook>
最佳回答

就我可以说,你的法典看得很好,但我认为你可以做些什么。 让我知道,这是否为你工作。

第一,检查该条是否获得批准。 如果该条文在草案文本中,数据在批准之前就得到了反映。

第二。 不是使用示范听众,而是试图用 h子来掩盖服务。

<service>
    <service-type>com.liferay.portlet.journal.service.JournalArticleService</service-type>
    <service-impl>com.example.hook.service.impl.JournalArticleServiceImpl</service-impl>
</service>

You ll need to implement its service wrapper, JournalArticleServiceWrapper.

Overwrite the update methods (there could be several) and call its parent method then do your logic. Like so:

public JournalArticle someUpdateArticleMethod(Many params) SomeExceptions {
    JournalArticle journalArticle = super.someUpdateArticleMethod(params);

    // my code here.
}

模范听众来做这项工作无疑比较容易。 虽然我不相信这是实际问题,但也许会有一个利用最新信息更新模型的问题,因为可以建立一个无限的通道。

问题回答

暂无回答




相关问题
Error getting SVN repo of Liferay in Eclipse

Im using Eclipse Galileo and have installed Subclipse. I looked at the svn repo url at http://www.liferay.com/web/brian.chan/blog/-/blogs/changes-to-anonymous-access-to-liferay-s-svn and then tried to ...

Liferay + google openid HOW?

Is there someone who knows how to use Liferay 5.2.3 the most up2date free version of liferay with google openid ? I ve try to use the http://www.google.com/accounts/o8/id url but it doesnt work. For ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

how to delete liferay s theme cache files? [closed]

i have developed a theme for liferay and i have deployed it. but when i choose the theme it doesnt recognize it s styles and it is reading styles from previous theme caches. how can i delete ...

热门标签