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

Extend AdvancedSearch widget

Former Member
0 Likes
1,029

Hi Experts! I would like to extend the AdvancedSearch widget in the backoffice. I have extended AdvancedSearchEngine widget previously and it worked, but I'm trying to do it in the same way with AdvancedSearch and it doesn't work.

Here is the xml from myextension-widgets.xml that have by now:

     <widget-extension widgetId="collapsibleContainer">
                 <remove widgetId="advancedSearch"/>
         <widget id="advancedSearch" widgetDefinitionId="myextensionpath.myextensionadvancedsearch"
                                         slotId="center" template="false">
         .
         . Specific widgets of the extension
         .
         <widget/>
         <widget-extension/>

The widget "myextensionpath.myextensionadvancedsearch" has as parent the "com.hybris.cockpitng.advancedsearch" widget.

Thanks!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Hi , You are right, I really should use "widget-extension", but anyway my controller override method is not called. I checked documentation and I see here https://help.hybris.com/6.7.0/hcd/8bda5dec866910148593fca2c20f6a0e.html in section "Extend the Widget Controller" that I really just need to define class and definition.xml - I tried this approach, but also without success, my method never gets called, do you have any idea?

/custom/projectbackoffice/backoffice/resources/widgets/advancedSearch/definition.xml

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
         <widget-definition extends="com.hybris.cockpitng.advancedsearch"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd">
             <controller class="project.hybris.backoffice.widgets.advancedsearch.ProjectAdvancedSearchController"/>
         </widget-definition>


And then /custom/projectbackoffice/backoffice/src/project/hybris/backoffice/widgets/advancedsearch/ProjectAdvancedSearchController.java with override initOrLoadAdvancedSearchModel method, which is never called.

former_member625836
Active Contributor
0 Likes

You are missing id for your extension. In definition.xml you just specify what to extend, while you also need to assign a new id for it. It has been changed in 1811, but in earlier versions you need to introduce new widget with new id to have different logic in controller.

Cheers, Jacek

Former Member
0 Likes

Thanks , it worked!

former_member625836
Active Contributor
0 Likes

Hi ,

You are defining a new widget instance rather then changing the existing one. To change existing one, you need to use widget-extension tag instead of widget. Your current widgets.xml is not somplient with schema.

Cheers, Jacek

Former Member
0 Likes

Hi! Any solution for this? Have same problem, my custom override method in my controller that I have defined in definition.xml is not called.

I have defined projectbackoffice/backoffice/resources/widgets/advancedSearch/definition.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <widget-definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/widget-definition.xsd"
                    id="project.hybris.backoffice.widgets.advancedsearch" extends="com.hybris.cockpitng.advancedsearch">
     <name>Advanced Search</name>
     <defaultTitle>Advanced Search</defaultTitle>
     <controller class="project.hybris.backoffice.widgets.advancedsearch.ProjectAdvancedSearchController"/>
 </widget-definition>

And later in projectbackoffice/resources/projectbackoffice-backoffice-widgets.xml

 <widget id="collapsibleContainer" widgetDefinitionId="com.hybris.cockpitng.collapsiblecontainer" slotId="perspectives" template="false">
     <remove widgetId="advancedSearch" />
     <widget id="projectAdvancedSearch" widgetDefinitionId="project.hybris.backoffice.widgets.advancedsearch"
             slotId="center" template="false">
         <widget id="advancedSearchEngine"
                 widgetDefinitionId="com.hybris.cockpitng.widgets.common.advancedsearchengine"
                 slotId="cockpitWidgetChildrenInvisible" template="false">
             ..
             <virtual-sockets/>
         </widget>
         <widget id="hmc2list" widgetDefinitionId="com.hybris.cockpitng.collectionBrowser"
                 slotId="nestedWidget" template="false">
             ..
         </widget>
         ..
         <virtual-sockets/>
     </widget>
 </widget>

Do I need to put "projectAdvancedSearch" somewhere else, so that overriding would work? Thanks!