Skip to Content
0
May 30, 2017 at 01:28 PM

Backoffice widget without type

211 Views

Hi all,

I need to create a widget that does not require a type. Lets say I want to expand the explorer-tree with an entry that reads "myWidget", when said entry is clicked, I want my custom widget loaded in the main area.

What I tried to do so far, is to edit my *-backoffice-config.xml:

     <context component="explorer-tree" merge-by="module">
         <explorer-tree:explorer-tree xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree" xmlns="http://www.hybris.com/cockpitng/config/explorertree">
                 <navigation-node id="myWidget"/>
         </explorer-tree:explorer-tree>
     </context>

I also created a definition.xml:

 <widget-definition id="com.company.hybris.widgets.cuppywidget" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd">
     <name>My Cuppy widget</name>
     <description>My own widget.</description>
     <defaultTitle>Nix</defaultTitle>
     <author>Me</author>
     <version>0.1</version>
 
 </widget-definition>


and a really simple .zul file:

 <widget xmlns="http://www.zkoss.org/2005/zul"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:h="http://www.w3.org/1999/xhtml"
         xmlns:w="http://www.zkoss.org/2005/zk/client"
         xmlns:zk="http://www.zkoss.org/2005/zk"
         xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.hybris.com/schema/cockpitng/zul/zul.xsd"
          height="100%">
          
     <div height="100%" style="background: #ccc;">
         <div>
 test
         </div>
     </div>
 </widget>

Actually it looks a little different, but you get the idea ;) Nothing is loaded from any type.

After that I edited the *-backoffice-wdgets.xml:

 <widget-extension widgetId="mainSlot">
     <widget id="hmc_treenode_mywidget_conditionevaluator" widgetDefinitionId="com.hybris.cockpitng.conditionevaluator"
             slotId="cockpitWidgetChildrenInvisible"
             template="false">
         <widget id="mywidget-evaluator"
                 widgetDefinitionId="com.hybris.cockpitng.widgets.common.propextractor"
                 slotId="cockpitWidgetChildrenInvisible"
                 template="false">
             <setting key="expression" type="String" value="id"/>
             <setting key="socketDataType_$T" type="String" value="java.lang.String"/>
             <setting key="widgetStyleAttribute" type="String" value=""/>
             <setting key="widgetStyleClass" type="String" value=""/>
             <virtual-sockets/>
         </widget>
         <setting key="expression" type="String"
                  value="#root.id EQ 'myWidget'"/>
         <setting key="socketDataType_$T" type="String"
                  value="com.hybris.backoffice.navigation.NavigationNode"/>
         <setting key="widgetStyleAttribute" type="String" value=""/>
         <setting key="widgetStyleClass" type="String" value=""/>
         <virtual-sockets/>
     </widget>
 </widget-extension>
 
 <widget-connection sourceWidgetId="explorerTree" outputId="nodeSelected"
                    targetWidgetId="hmc_treenode_mywidget_conditionevaluator" inputId="input"/>
 <widget-connection sourceWidgetId="hmc_treenode_mywidget_conditionevaluator" outputId="true"
                    targetWidgetId="com.company.hybris.widgets.cuppywidget"
                    inputId="genericInput"/>


As this does not work, could somebody please explain what I am doing wrong? Is what I am trying possible at all? Help is greatly appreciated!

Thanks, Paul