on ‎2022 Feb 16 12:48 PM
Hello,
I want to use ToggleAction in my widget, but I can't connect the action with my widget. What am I missing?
I have defined my widget in [extensinon]/widgets/actions/mywidget with definition.xml and added a corresponding controller
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<widget-definition id="[mypackage].backoffice.widgets.productfilter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd">
<name>mywidget</name>
<description>My own widget.</description>
<defaultTitle>widget</defaultTitle>
<author>Me</author>
<version>0.1</version>
<controller class="[mypackage].backoffice.widgets.mywidget.MyWidgetController"/>
<sockets>
</sockets>
</widget-definition>
I added the toogle-action where I need it in [myextension]-backoffice-config.xml
<context type="Product" component="pcmbackoffice-assortment-listviewactions">
<y:actions>
<y:extended-group qualifier="common">
<y:action id="pcm-myaction" action-id="com.hybris.cockpitng.action.toggle" osition="70">
<y:parameter>
<y:name>outputValue</y:name>
<y:value>"toggle"</y:value>
</y:parameter>
<y:parameter>
<y:name>toggleInput</y:name>
<y:value>toggleState</y:value>
</y:parameter>
<y:parameter>
<y:name>defaultActive</y:name>
<y:value>false</y:value>
</y:parameter>
<y:parameter>
<y:name>iconUri</y:name>
<y:value>cng/images/pcmbackoffice-back-action.png</y:value>
</y:parameter>
</y:action>
</y:extended-group>
</y:actions>
</context>
Then I added the widget under [myextension]-backoffice-widgets.xml
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widgets.xsd">
<widget id="mywidget" widgetDefinitionId="[myextension].backoffice.widgets.mywidget" template="false">
<virtual-sockets>
<input id="toggleState" type="java.lang.String"/>
<output id="output" type="java.lang.String"/>
</virtual-sockets>
</widget>
<widget-connection sourceWidgetId="mywidget" outputId="output"
targetWidgetId="mywidget" inputId="toggleState"/>
</widgets>
and last the Controller with:
public class MyWidgetControllerController extends DefaultWidgetController {
@Override
public void initialize(final Component comp) {
super.initialize(comp);
}
@SocketEvent(socketId = "output")
public void productfilter(String toggleState)
{
sendOutput("toggleState", "active");
}
}
Request clarification before answering.
You are not triggering your widget with the action. If you look examples of PCM for widget pcmbackoffice-toolbar, there is the following setting
<setting key="toolbarActions" type="String" value="pcmbackoffice-navibar-actions"/>And also there is a context with component pcmbackoffice-navibar-actions which contains toggle actions.
I think you need to add the following setting to your widget definition (you may also want to change the component name)
<setting key="toolbarActions" type="String" value="pcmbackoffice-assortment-listviewactions"/>This way, you action will send message to your widget
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 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.