on 2019 Apr 03 1:27 PM
This happens in Version 18.11.4, problem was not happening in 18.08
I'm trying to add a simple action to the product list view in the product cockpit perspective. Backoffice framework can't find the action definition.
this is what I've done so far.
I created the action definition and put it in /my-backoffice-extension/backoffice/resources/widgets/actions/generateartiklepassaction
<action-definition id="de.frutarom.cockpitng.action.generateartiklepass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
<name>GenerateArtiklePassAction</name>
<description>Generates Artikle Pass for selected products</description>
<author>danielv</author>
<version>0.1</version>
<actionClassName>de.frutarom.backoffice.widgets.actions.artiklepass.GenerateArtiklePassAction</actionClassName>
<inputType>java.util.Collection</inputType>
<iconUri>icons/icon_action_artiklepass_default.png</iconUri>
<iconHoverUri>icons/icon_action_artiklepass_hover.png</iconHoverUri>
<iconDisabledUri>icons/icon_action_artiklepass_disabled.png</iconDisabledUri>
</action-definition>
I I created the action handler class and place it in the src folder under myextension/backoffice/src/...
public class GenerateArtiklePassAction implements CockpitAction<Object, Object> {
@Resource
private ArtiklePassService artiklePassService;
@Resource
public ObjectFacade objectFacade;
@Override
public ActionResult<Object> perform(ActionContext<Object> actionContext) {
List<ProductModel> ctxProducts = this.getDataAsCollection(actionContext);
ctxProducts.stream().forEach(artiklePassService::generateArtiklePassForProduct);
return new ActionResult(ActionResult.SUCCESS);
}
@Override
public boolean canPerform(ActionContext<Object> ctx) {
if (ctx.getData() == null) {
return false;
} else if (ctx.getData() instanceof Collection) {
Collection selectedItems = (Collection)ctx.getData();
ObjectFacadeOperationResult reloadResult = this.getObjectFacade().reload(selectedItems);
Collection refreshedItems = reloadResult.getSuccessfulObjects();
return isCollectionReady(refreshedItems);
}else{
return !getObjectFacade().isNew(ctx.getData());
}
}
private List<ProductModel> getDataAsCollection(ActionContext<Object> ctx) {
List<ProductModel> ctxObjects = new ArrayList();
if (ctx.getData() instanceof Collection) {
ctxObjects.addAll((Collection<ProductModel>)ctx.getData());
} else {
ctxObjects.add((ProductModel)ctx.getData());
}
return ctxObjects;
}
private boolean isCollectionReady(Collection<ProductModel> collection){
return CollectionUtils.isNotEmpty(collection) && collection.stream().noneMatch(getObjectFacade()::isNew);
}
@Override
public boolean needsConfirmation(ActionContext<Object> ctx) {
return true;
}
@Override
public String getConfirmationMessage(ActionContext<Object> ctx) {
return ctx.getLabel("artiklepass.confirm");
}
public ArtiklePassService getArtiklePassService() {
return artiklePassService;
}
public void setArtiklePassService(ArtiklePassService artiklePassService) {
this.artiklePassService = artiklePassService;
}
public ObjectFacade getObjectFacade() {
return objectFacade;
}
public void setObjectFacade(ObjectFacade objectFacade) {
this.objectFacade = objectFacade;
}
}
I created the ui config in my-backoffice-extension/resourcces/my-backoffice-extension-backoffice-config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config"
xmlns:y="http://www.hybris.com/cockpit/config/hybris"
xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"
xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree"
xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"
xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"
xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch"
xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch"
xmlns:dsb="http://www.hybris.com/cockpitng/config/dashboard">
<!-- frutarombackoffice UI configuration should be provided here -->
<context type="Product" component="pcmbackoffice-listviewactions" merge-by="type" >
<y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:group qualifier="common" show-group-header="false">
<y:label>actiongroup.common</y:label>
<y:action action-id="de.frutarom.cockpitng.action.generateartiklepass" property="selectedObjects"/>
</y:group>
</y:actions>
</context>
<context type="Product" component="pcmbackoffice-assortment-listviewactions" merge-by="type" >
<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="de.frutarom.cockpitng.action.generateartiklepass" property="selectedObjects"/>
</y:group>
</y:actions>
</context>
<context component="pcm-quicklist-actions" type="Product" merge-by="type" >
<y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:three-dots-group qualifier="common">
<y:label>actiongroup.common</y:label>
<y:action action-id="de.frutarom.cockpitng.action.generateartiklepass" property="selectedObjects"/>
</y:three-dots-group>
</y:actions>
</context>
</config>
I can see that my-backoffice-extension_bof.jar is being generated and if I open it, I can see my action definition and I can see the handler class.
I've tried multiple times to refresh backoffice config in F4 menu.
An I always get the same result. The action button is not displayed and I get this warn in the log:
WARN [hybrisHTTP1] [Action] could not find action definition for code [de.frutarom.cockpitng.action.generateartiklepass]
As an interesting fact, this same warn shows up for OOTB actions such as "run cronjob" and the actions are not visible, this makes me think that is a backoffice bug.
WARN [hybrisHTTP1] [Action] could not find action definition for code [com.hybris.cockpitng.action.runcronjob]
WARN [hybrisHTTP1] [Action] could not find action definition for code [com.hybris.cockpitng.action.abortcronjob]
WARN [hybrisHTTP1] [Action] could not find action definition for code [de.hybris.platform.platformbackoffice.actions.deletecronjoblogs.DeleteCronJobLogsAction]

Any suggestions on how to make this work ?
Request clarification before answering.
Hello,
In my case there was missing a "/" in the name tag. I mean, the xml structure of the definition.xml file was wrong.
Hope this helps!
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did anyone make it work ? Please share your solution for this, i have same error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.