问题
I'm trying to create a widget that can communicate with another one through sockets. I've followed the documentation from here but I couldn't understand how their example works. I've created the definition.xml
where I've defined the inputs/outputs, mychat.zul
and the controller
. But I couldn't find anywhere in the platform the tag <widget-connection>
to see that the widget is actually connecting the inputs/outputs to something.. or isn't this the purpose of the tag above?
I've added the widgets via backoffice F4 functionality but their example works only if I add two widgets and SET the connection between them (because I tried to debug the program and see when it enters in @SocketEvent
method and it enters only when I have 2 widgets and set the outcomingMsg
and incomingMsg
, but isn't enough to only set the <widget-connection>
with the same sourceWidgetId and targetWidgetId ?).
Maybe I don't understand completely how this works.. If someone can help me I would appreciate :) Thanks.
P.S.: I followed the steps from the tutorial above, I am sure that I've created them in the right directory, otherwise it wouldn't work at all.
Here is the <widget-connection>
from trainingbackoffice-backoffice-widgets.xml
<widget-connection sourceWidgetId="com.training.backoffice.widgets.mychat" outputId="outgoingMsg" targetWidgetId="com.training.backoffice.widgets.mychat" inputId="incomingMsg"/>
EDIT : Isn't there a way to have only one chat window to communicate with itself ?
回答1:
SOLVED
The <widget-connection>
works as I expected BUT -> my widget wasn't instantiated, so I've solved the problem by instantiating it in trainingbackoffice-backoffice-widgets.xml
like this:
<widget id="myChat" widgetDefinitionId="com.training.backoffice.widgets.mychat" />
and the widget connection like this:
<widget-connection sourceWidgetId="myChat" outputId="outgoingMsg" targetWidgetId="myChat" inputId="incomingMsg"/>
来源:https://stackoverflow.com/questions/59854207/hybris-widget-connection-through-socket-id