通过Liferay表单发送的自定义电子邮件 [英] Custom email sent by Liferay Form

查看:21
本文介绍了通过Liferay表单发送的自定义电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖Liferay表单发出的电子邮件通知。我遵循了本主题中的技巧:https://community.liferay.com/it/forums/-/message_boards/view_message/104934134。 没有骰子。我已经成功地添加了DDLFormEmailNotificationSender的自定义实现。注册正确,(具有正确的服务)。如果我签出注册的服务,我的自定义DDLFormEmailNotificationSender会显示在顶部。但是当我提交表单时,Liavay继续使用"普通"DDLFormEmailNotificationSender,而不是我的自定义DDLFormEmailNotificationSender。有什么窍门吗?

我的DDLFormEmailNotificationSender如下所示:

@Component(
    immediate = true,
    property = {
            "service.ranking:Integer=100"
    },
    service = DDLFormEmailNotificationSender.class
)
public class CustomDDLFormEmailNotificationSender extends DDLFormEmailNotificationSender {

    private static final String CUSTOM_TEMPLATE_PATH = "";

    @Override
    protected Template createTemplate(
        PortletRequest portletRequest, DDLRecordSet recordSet,
        DDLRecord record) throws PortalException {

        Template template = TemplateManagerUtil.getTemplate(TemplateConstants.LANG_TYPE_SOY,
        getTemplateResource(CUSTOM_TEMPLATE_PATH), false);

        populateParameters(template, portletRequest, recordSet, record);

        return template;
    }
}

(我知道CUSTOM_TEMPLATE_PATH现在为空。但这仅用于测试目的。

我已经创建了一个片段来公开私有包,如论坛帖子中所述:

Bundle-Name: liferay-xxx-dynamic-data-lists-form-override
Bundle-SymbolicName: liferay.xxx.dynamic.data.lists.form.override
Fragment-Host: com.liferay.dynamic.data.lists.form.web;bundle-version="2.0.15"

Export-Package: com.liferay.dynamic.data.lists.form.web.internal.notification
-jsp: *.jsp,*.jspf
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
-plugin.resourcebundle: com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
-plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin
-sass: *

所以您可以看到我已经公开了"com.liferay.dynamic.data.lists.form.web.internal.notification"包。

如果我在Apache Gogo中检查DDLFormEmailNotificationSender:

services | grep DDLFormEmailNotificationSender
{com.liferay.dynamic.data.lists.form.web.internal.notification.DDLFormEmailNotificationSender}={service.ranking=100, component.name=be.xxx.portal.website.form.CustomDDLFormEmailNotificationSender, component.id=519, service.id=299, service.bundleid=757, service.scope=bundle}
{com.liferay.dynamic.data.lists.form.web.internal.notification.DDLFormEmailNotificationSender}={component.name=com.liferay.dynamic.data.lists.form.web.internal.notification.DDLFormEmailNotificationSender, component.id=811, service.id=2629, service.bundleid=143, service.scope=bundle}
true

我正在使用Liferay 7.0。

推荐答案

我已从Liferay社区获得一些支持,并了解如何修复该问题。

以上配置正确!但是,引用DDLFormEmailNotification的(救生索)服务有这个引用静电/不情愿。我必须创建一个配置文件放到我的OSGi/configs文件夹中,它定义了正确的实现。(我的CustomDDLFormEmailNotificationSender)。

我的配置文件名为:com.liferay.dynamic.data.lists.form.web.internal.portlet.action.AddRecordMVCActionCommand.config

这是因为我需要配置AddRecordMVCAction命令。(配置在那里定义为静电/不情愿的引用)。

它包含:

DDLFormEmailNotificationSender.target="(component.name=be.xxx.portal.website.form.CustomDDLFormEmailNotificationSender)"
它的基本意思是:DDLFormEmailNotificationSender(是那里的引用名称),应该是:be.xxx.portal.website.form.CustomDDLFormEmailNotificationSender.

确保正确部署该组件,因为一旦配置,就不会回退到原始实现。(如果删除该配置,OSGi将回退)。

来源:https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-0/overriding-service-references#find-the-component-and-service-reference

希望这能帮助某人。

这篇关于通过Liferay表单发送的自定义电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆