自定义动作实施Magnolia CMS

时间:2019-11-21 15:21:49

标签: magnolia

我尝试在操作栏中为Magnolia中的页面应用实现自定义操作,类似于Magnolia 6.0 custom action implementation

我的实现是:

package ch.zzz.module.versioning;


import info.magnolia.ui.api.action.Action;
import info.magnolia.ui.api.action.ActionExecutionException;
import info.magnolia.ui.api.action.ConfiguredActionDefinition;

public class ZzzVersioning extends ConfiguredActionDefinition {

    public ZzzVersioning() {
        this.setImplementationClass(MyAction.class);
    }
}

class MyAction implements Action {



    @Override
    public void execute() throws ActionExecutionException {
        System.out.println("Hello! Executed MyAction");
    }
}

页面应用程序的操作配置使用ch.zzz.module.versioning.ZzzVersioning类,我在页面应用程序的操作栏中列出了该操作。

配置应用 模块>页面>应用程序>页面>子应用程序>浏览器>操作> MyActions -class = ch.zzz.module.versioning.ZzzVersioning

modules> pages> apps> pages> subApps> browser> actionbar> sections> pageActions> importExportActions> items-MyAction

在操作栏中单击MyAction时,我收到一条错误消息:Could not instantiate action class for action: MyAction.

这是我在日志中得到的:

2019-11-22 08:37:26,498 ERROR fo.magnolia.ui.contentapp.browser.BrowserPresenter: An error occurred while executing action [MyAction]
info.magnolia.ui.api.action.ActionExecutionException: Could not instantiate action class for action: MyAction

...然后在堆栈末尾:

Caused by: info.magnolia.objectfactory.MgnlInstantiationException: No suitable constructor found for class [class ch.zzz.module.versioning.MyAction]
        at info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:124) ~[magnolia-core-5.6.10.jar:?]
        at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:132) ~[magnolia-core-5.6.10.jar:?]
        at info.magnolia.ui.framework.ioc.UiContextBoundComponentProvider.lambda$newInstanceWithParameterResolvers$4(UiContextBoundComponentProvider.java:113) ~[magnolia-ui-framework-5.6.10.jar:?]
        at info.magnolia.ui.framework.ioc.UiContextBoundComponentProvider.provideInCurrentScope(UiContextBoundComponentProvider.java:125) ~[magnolia-ui-framework-5.6.10.jar:?]
        at info.magnolia.ui.framework.ioc.UiContextBoundComponentProvider.newInstanceWithParameterResolvers(UiContextBoundComponentProvider.java:113) ~[magnolia-ui-framework-5.6.10.jar:?]
        at info.magnolia.ui.framework.ioc.UiContextBoundComponentProvider.newInstance(UiContextBoundComponentProvider.java:108) ~[magnolia-ui-framework-5.6.10.jar:?]
        at info.magnolia.ui.api.action.AbstractActionExecutor.createAction(AbstractActionExecutor.java:90) ~[magnolia-ui-api-5.6.10.jar:?]
        ... 129 more

任何建议如何使其正常工作?

1 个答案:

答案 0 :(得分:2)

您必须将自己的课程公开,以便IOC系统可以找到它。但是,如果您使用注入机制,则可以使构造函数成为私有函数。

干杯

希望有帮助