on 2018 Sep 04 1:08 PM
Hi, I'm having problems when I try to add a new action in backoffice.
I'm using hybris 6.6. The new action is called 'GenerateReportAction'.
This is my definition.xml that is placed in /bacoffice/resources/widgets/actions/generatereportaction
<action-definition id="com.hybris.cockpiting.action.sendregistrationinvite"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
<name>Generate report</name>
<description>Generate a new report</description>
<author>***</author>
<version>0.1</version>
<actionClassName>com.<company>.backoffice.actions.GenerateReportAction</actionClassName>
<inputType>java.lang.Object</inputType>
<outputType>java.lang.Object</outputType>
<!--<iconUri>icons/send_registration_invite.png</iconUri>
<iconDisabledUri>icons/send_registration_invite_disabled.png</iconDisabledUri>-->
</action-definition>
This is my new action class file. At this momen, this file is in /backoffice/src/com/ (company)/backoffice/actions/GenerateReportAction.java
package com.<company>.backoffice.actions;
import com.hybris.cockpitng.actions.ActionContext;
import com.hybris.cockpitng.actions.ActionResult;
import com.hybris.cockpitng.actions.CockpitAction;
import org.zkoss.zul.Messagebox;
public class GenerateReportAction implements CockpitAction<Object, Object> {
@Override
public ActionResult<Object> perform(final ActionContext<Object> ctx) {
ActionResult<Object> result = null;
final Object data = ctx.getData();
if (data != null) {
result = new ActionResult<Object>(ActionResult.SUCCESS, ctx.getLabel("action.generateSeoReport.confirm", new Object[]{data}));
} else {
result = new ActionResult<Object>(ActionResult.ERROR);
}
Messagebox.show(result.getData() + " (" + result.getResultCode() + ")");
return result;
}
@Override
public boolean canPerform(final ActionContext<Object> ctx) {
final Object data = ctx.getData();
return (data instanceof String) && (!((String) data).isEmpty());
}
@Override
public boolean needsConfirmation(final ActionContext<Object> ctx) {
return true;
}
@Override
public String getConfirmationMessage(final ActionContext<Object> ctx) {
return ctx.getLabel("action.generateSeoReport.sent");
}
}
And at the end, I added this code in the (backofficeExtension)-backoffice-config.xml
<context merge-by="module" type="CustomReport" component="listviewactions">
<y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:group qualifier="common">
<y:label>actiongroup.common</y:label>
<y:action action-id="com.<company>.backoffice.actions.GenerateReportAction" property="selectedObjects" />
<y:action action-id="com.hybris.cockpitng.action.delete" property="selectedObjects" triggerOnKeys="#del"/>
<y:action action-id="com.hybris.cockpitng.action.create" property="pageable.typeCode" />
<y:action action-id="com.hybris.cockpitng.listview.action.export.csv" property="exportColumnsAndData"/>
</y:group>
</y:actions>
</context>
Whe I go to that CustomReport listView, I can see in console a warning saying "WARN [hybrisHTTP5] [Action] could not find action definition for code [com.(company).backoffice.actions.GenerateReportAction]
What is wrong? Is needed a iconUri in the dfinition to be able to see the button?
Thank you
Change the action ID in your backoffice-config.xml to the one you declared in your definition.xml .
It is unable to find an action with that id declared in the configuration.xml file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As far as I remember you need to use in the backoffice config's "action-id" the "id" attribute value of the action-definition tag within the definition.xml. Now you have there this:
<action-definition id="com.hybris.cockpiting.action.sendregistrationinvite"...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.