Reference Search Widget

The Reference Search widget enhances search in references and serves as a base for the Reference Advanced Search Group widget.

Widget Definition

Name Reference Search Widget
ID com.hybris.cockpitng.backoffice.referenceadvancedsearch
Category Search
Description It is intended to allow user to perform advanced search for references.
Applied In All
Based On Not applicable
Author SAP
Inputs Details of input sockets:
  • referenceSearchCtx
    • Type: com.hybris.cockpitng.data.TypeAwareSelectionContext
    • Multiplicity: Single
    • Description: It is a POJO object send by reference editor. For more details, refer to configuration section.
  • resetSelection
    • Type: java.lang.Object
    • Multiplicity: Single
    • Description: Resets selection (disables Select button). It might be useful when a new search is performed.
  • selectedItems
    • Type: [T]
    • Multiplicity: List
    • Description: List of items selected by the user when widget is in multi select mode. As a result, Select button is enabled and shows the number of selected items.
  • selectedItem
    • Type: java.lang.Object
    • Multiplicity: Single
    • Description: Item selected by the user when widget is in single selection mode. Select button is enabled and its name is updated.
Outputs Details of output sockets:
  • advancedSearchInitCtx
    • Type: com.hybris.backoffice.widgets.advancedsearch.impl.AdvancedSearchInitContext
    • Multiplicity: Single
    • Description: An object on this socket is sent to perform a search after incoming data on referenceSearchInitCtx is parsed. For more information, refer to Advanced Search Widget,
  • selectedReferences
    • Type: java.lang.Object
    • Multiplicity: List
    • Description: List of references selected by the user. In case of single selection mode the list has only one item.
  • cancel
    • Type: com.hybris.cockpitng.data.TypeAwareSelectionContext
    • Multiplicity: Single
    • Description: Sends socket output when user clicks Cancel button.
Generated Events Not applicable

Configuration

The widget is configured by data that is sent to referenceSearchCtx that accepts com.hybris.cockpitng.data.TypeAwareSelectionContext. It contains the following fields utilized by the widget:

  • @typeCode (java.lang.String): type of items to search for
  • @multiselect (java.lang.Boolean): tells if user is able to select multiple items, value of this field sets a setting on collectionBrowser widget slot (widget that is placed there).
  • parameters (java.util.Map): list of parameters. In general, all parameters passed to editor should be included in this list. This allows to utilize the following functionalities:
    • Narrowing search results: all matching params of editor are translated to advanced search init ctx. Refer to Narrowing Search Results section in Default Reference Editor
    • Forwarding params to widget slots as its settings. If editor parameter is passed to a widget slot, it should be prefixed with its name.
      • advancedSearch/paramName: it results in a setting set on advancedSearch widget slot
      • collectionBrowser/paramName: it results in a setting set on advancedSearch widget slot

Example

There is a direct and strict interdependency between Reference Search, Reference Advanced Search Group, Advanced Search widgets, and Reference Editors. An example of how to configure the settings of advanced reference searching at runtime is visible in the sample of cockpit-config.xml file:

Enabling Reference Search for Supercategories:

<editorArea:tab name="hmc.tab.product.categorysystem" position="10">
	<editorArea:section name="hmc.section.product.productincategory">
		<editorArea:attribute qualifier="supercategories">
			<editorArea:editor-parameter>
				<editorArea:name>advancedSearch/advancedSearchConfigCtxCode</editorArea:name>
				<editorArea:value>ABC</editorArea:value>
			</editorArea:editor-parameter>
          </editorArea:attribute>
	</editorArea:section>
</editorArea:tab>

See an example of advancedSearch/advancedSearchConfigCtxCode configuration:

<context type="Category" component="ABC" module="platformbackoffice">
	<advanced-search:advanced-search xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch" xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms" xmlns:dsb="http://www.hybris.com/cockpitng/config/dashboard" xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea" xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree" xmlns:list-view="http://www.hybris.com/cockpitng/component/listView" xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch" xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config" xmlns:y="http://www.hybris.com/cockpit/config/hybris" connection-operator="OR">
		<advanced-search:field-list disable-attributes-comparator="true" disable-subtypes-checkbox="true">
			<advanced-search:field name="code" operator="contains" selected="true"/>
               <advanced-search:field name="name" operator="contains" selected="true"/>
               <advanced-search:field name="catalogVersion" operator="equals" selected="true"/>
               <advanced-search:field name="allowedPrincipals" selected="false"/>
               <advanced-search:field name="categories" selected="true"/>
               <advanced-search:field name="description" selected="true"/>
               <advanced-search:field name="keywords" selected="false"/>
               <advanced-search:field name="medias" selected="false"/>
               <advanced-search:field name="order" selected="false"/>
               <advanced-search:field name="picture" selected="false"/>
               <advanced-search:field name="products" selected="false"/>
               <advanced-search:field name="supercategories" selected="false"/>
               <advanced-search:field name="thumbnail" selected="false"/>
               <advanced-search:field name="comments" selected="false"/>
               <advanced-search:field name="creationtime" selected="false"/>
               <advanced-search:field name="itemtype" selected="false"/>
               <advanced-search:field name="modifiedtime" selected="false"/>
               <advanced-search:field name="owner" selected="false"/>
               <advanced-search:field editor="com.hybris.cockpitng.editor.defaultlong" name="pk" selected="false"/>
		</advanced-search:field-list>
          <advanced-search:sort-field asc="false" name="code"/>
	</advanced-search:advanced-search>
</context>

Widget Preview

By design Reference Search widget is displayed in a modal window when you click search button in reference editor. However, this widget does not provide full functionality until it is correctly configured, and proper widgets are placed in the widget slots. You can see an example of its full functionality presented in Reference Advanced Search Group Widget, which utilizes the Reference Search as a skeleton. It uses the Advanced Search and Collection Browser slots here:

Settings

Not applicable

Widget Slots

slotID Multiplicity Type Slots Composition
advancedSearch single Not applicable Intended to contain Advanced Search widget. It is displayed in the top section and allows user to define search conditions.
collectionBrowser single Not applicable Intended to contain Collection Browser widget. It is displayed in the middle of a widget and allows user to select references.
cockpitWidgetChildrenInvisible multi Not applicable A general-purpose slot available for widgets. Any widget placed on this slot is not displayed in the application view but can be accessed through its socket API.