cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to connect Action with Widget over SocketEvent

0 Likes
581

Hello,

I want to connect a Action with a Widget to call refresh from the CollectionBrowserController. I assumed it would work if the following steps are taken. Inspiration example was e.g. Action with id="com.hybris.backoffice.widgets.actions.excel.export"

In the CollectionBrowserControler I want to call

@SocketEvent(
socketId = "refresh"
)
public void refresh() {
this.refreshPageable();
}

First of all setting the action definition.xml with the output-socket

<action-definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br>                   id="net.netconomy.hgd.backoffice.actions.myaction"<br>                   xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd"><br><br>    <name>My Action</name><br>    <description>my action</description><br>    <author>hybris</author><br>    <version>1.0</version><br><br>    <actionClassName>net.netconomy.hgd.backoffice.actions.MyActionAction</actionClassName><br><br>    <sockets><br>        <output id="refresh" type="java.lang.Object"/><br>    </sockets><br><br>    <iconUri>icons/icon_action.png</iconUri><br>    <iconDisabledUri>icons/icon_action_disabled.png</iconDisabledUri><br>    <iconHoverUri>icons/icon_action_hover.png</iconHoverUri><br><br></action-definition>

Then creating the Action extending AbstractComponentWidgetAdapterAware

public class MyActionAction extends AbstractComponentWidgetAdapterAware implements CockpitAction<Object, Object> {<br><br>    @Override<br>    public ActionResult<Object> perform(ActionContext<Object> ctx) {<br>        ActionResult<Object> result = new ActionResult(ActionResult.SUCCESS, null);<br>
// some logic<br>        this.sendOutput("refresh", ctx.data)<br><br>        return result;<br>    }<br>}

Last but not least set up the widget configuration and connection with

    <context type="Product" component="pcmbackoffice-assortment-listviewactions"><br>        <y:actions><br>            <y:extended-group qualifier="common"><br>                <y:action action-id="net.netconomy.hgd.backoffice.actions.myaction" property="selectionContext" position="50"/><br>            </y:extended-group><br>        </y:actions><br>    </context>
<br><widget-connection sourceWidgetId="STUB_com.hybris.backoffice.widgets.actions.myaction" outputId="refresh" targetWidgetId="pcmbackoffice-collectionBrowser-browser" inputId="refresh"/>

However, the refresh-method in CollectionBrowserController never is called and I had to solve the problem with Event+CRUD Operation. Anyone an idea what I forgot?

Accepted Solutions (0)

Answers (0)