Search code examples
sap-commerce-cloudbackoffice

How to perform refresh operation on widget from class that implements CockpitAction<I, O> interface


Good day.

Is there any solution for calling refresh operation on widget in class that implements CockpitAction interface. Generally speaking, you should implement this interface in order to use your own action in the backoffice. So in my case it is buttons in the subscription page: enter image description here

On the picture you can see 4 different buttons, this is not out of the box functionality of backoffice, so you should implement it by yourself. 4 buttons = 4 actions. When you press button there is a method:

ActionResult perform(ActionContext var1);

Which is called to perform required logic.

And there is method:

default boolean canPerform(ActionContext ctx) { return true; }

Which is used to check if this button set to active or passive state, like is it clickable or not.

The problem is that, when you press the button and it should become inactive it still is active, because no refresh is triggered, you can trigger refresh manually by clicking refresh button. Ideally, the refresh should be triggered after pressing action button in perfrom() method: enter image description here

I've made searching and did not find the way to trigger refresh operation from the code of class that implements CockpitAction interface. The logic of how backoffice is build is very complex and not well documented, so I even did not find the right function for triggering refresh.

If you have worked with SAP Hybris and know Backoffice well, can you please help to figure this out.

Thanks in advance!


Solution

  • In the perform method just set result.setStatusFlags(EnumSet.of(StatusFlag.OBJECT_MODIFIED));

    public ActionResult<T> perform(final ActionContext<T> obj)
    {
    -------- some logic --------
        final ActionResult result = new ActionResult(ActionResult.SUCCESS);
        result.setStatusFlags(EnumSet.of(StatusFlag.OBJECT_MODIFIED));
        return result;
    }