Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
12c (12.2.1.4.0)

E81455-02

<af:searchSection>

af:searchSection searchSection search section

UIComponent class: oracle.adf.view.rich.component.rich.data.RichSearchSection
Component type: oracle.adf.RichSearchSection

The af:searchSection component represents a group of data to be used by the inputSearch component. There are primarily two kinds of searchSection

The default searchSection should provide a master list of data. Search section of any other type should provide a list that is subset of default searchSection.

Filtering of data is supported only on default searchSection.

In the UI, inputSearch component considers two types of view.

  1. Initial view
  2. Filtering view

In the initial view, data from non-default searchSections and af:suggestionsSection is displayed. In the filtering view, only filtered data from default searchSection will be displayed. If af:suggestionsSection or a non-default searchSection is not provided, only in such a case is data from default searchSection is displayed in the initial view.

Code Example(s)

<af:inputSearch label="Label" valueAttribute="id">
              <af:searchSection type="default" dataUrl="/rest/employees" />
            </af:inputSearch>
   

Events

Type Phases Description
org.apache.myfaces.trinidad.event.AttributeChangeEvent Invoke Application,
Apply Request Values
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change event might include the width of a column that supported client-side resizing.

Supported Facets

Name Description
header HTML template to be used as per section header. Mustache is the templating system supported by the component. In single selection mode, this facet is applicable only for non-default searchSection. In multi selection mode, the facet on default searchSection will serve the template for the selections list.

Attributes

Name Type Supports EL? Description
attributeChangeListener javax.el.MethodExpression Only EL a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing.
binding oracle.adf.view.rich.component.rich.data.RichSearchSection Only EL an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean.
dataUrl String Yes REST service endpoint URI that provides a list of suggestions for the search section. This attribute supports these various types of URIs:
  • absolute - an absolute path, like "http://samplerest.com/rest/Emp"
  • context relative - a path relatively based on the web application's context root, like "/rest/Emp"
  • server relative - a path relatively based on the web server by application name, like "//RESTWebService-context-root/rest/Emp"

The REST response should strictly be in JSON format. The component will set the "Accept" header to "application/json" for the REST calls made.

The JSON document should have a root property labeled "items" and its value should be an array. If "items" property isn't available, the first root property whose value is an array is chosen as the list of suggestions.

Note: If the REST endpoint is on a different origin, CORS needs to be setup on the endpoint.

filter String Yes This attribute holds the name of the JS callback that would perform Array.filter operation on the default searchSection's collection returned from the REST response. The suggestions filtered by the JS callback will be shown as a separate section in the UI. Such a client filtered suggestion list is equivalent to a non default url provided af:searchSection. This attribute can't be set on the searchSection of type default The component instance will be set as context during JS callback invocation. The row object passed to the callback will have the structure below
  • data: The raw row data
  • index: The index of the row in the collection fetched from the REST call
  • key: The key value for the row
The index of the row object in the collection that is being filtered is also passed as an parameter to the callback. e.g. Suppose the 24th row data object is as below and the valueAttribute is 'EmpNo'
{
          'EmpNo': 1234,
          'Ename': 'Somename'
        }

the object passed to this method will be of format

{
          'data': {
            'EmpNo': 1234,
            'Ename': 'Somename'
          },
          'index': 24,
          'key': 1234
        }

Sample JS method:

function smartListFiltering(rowObj, rowIndex)
        {
          return rowObj.data['isReportee'] == true;
        }
filterParameters String Yes Attribute to set the query parameters on REST endpoint for
  1. filtering of the suggestions on the REST service for a given set of search terms
  2. fetching the full row (suggestion) objects from the REST service for a given set of key values

The REST call for fetching the desired resultset is attempted only if the master collection size is beyond the configured fetch limit set on the REST service and the REST response has "hasMore" property set. Otherwise the relevant filtering to obtain the desired resultset is completely done on the client and this attribute is not invoked.

Note 1: Dependency based filtering should also happen on the server, and it will not be done on the client whenever server filtering is being attempted.

Note 2: A converter needs to be attached to the inputSearch component to derive the display value from the displayAttributes when the master collection size is beyond the configured fetch limit.

Note 3: Since searchSection of type default provides the master collection and since only this collection is filterable, this attribute is only applicable for default searchSection.

This attribute holds the name of the JS callback. This JS callback is invoked when a REST call is being made

  1. in response to user action of filtering.
  2. to fetch the full row objects of the selected values

The searchSection client component instance will be set as context during JS callback invocation. A request and context objects will be passed as parameters to the function. The callback should return the configured passed in request object.

The request object will have the structure below:

  • queryString: The string set on this property will be appended as a query parameter to the REST url while making the HTTP request call. If the queryString has a query parameter that is already present in the base url, such a query parameter on the base url will be replaced with the new value in queryString.

    Recommendation: Relevant portions of queryString should be encoded correctly by passing it to encodeURIComponent browser API.

  • method: The request method, e.g., GET, POST. Default is GET
  • body: The request body for POST requests

The context object will have the structure below:

  • criteria: AdfRichInputSearch.CRITERIA_STARTS_WITH, AdfRichInputSearch.CRITERIA_CONTAINS, AdfRichInputSearch.CRITERIA_ATTRIBUTE_STARTS_WITH or AdfRichInputSearch.CRITERIA_VALUE_EQUALS. Indicates the search that needs to be performed
  • searchTerms: Array of search terms for AdfRichInputSearch.CRITERIA_STARTS_WITH, AdfRichInputSearch.CRITERIA_ATTRIBUTE_STARTS_WITH and AdfRichInputSearch.CRITERIA_CONTAINS. Or array of selected keys or values for which full row object needs to be fetched in case of AdfRichInputSearch.CRITERIA_VALUE_EQUALS
  • filterAttributes: Array of attributes across which the search needs to be filtered. For the case of AdfRichInputSearch.CRITERIA_VALUE_EQUALS, this will have a single value, the valueAttribute of the inputSearch component
Sample JS method:
function queryParamProvider(request, context)
        {
  if (context.criteria == AdfRichInputSearch.CRITERIA_VALUE_EQUALS)
    return selectedQueryParamProvider(request, context);

          request.queryString = "q=";
          for (each item in context.filterAttributes)
            for (each item in context.searchTerms)
              // append the relevant string to request['queryString'];

          return request;
}

function selectedQueryParamProvider(request, context)
{
  var values = context.searchTerms;
  var valueAttribute = context.filterAttributes[0];
  var q = "q=";
  for (var i = 0; i < values.length; i++)
  {
    if (i == 0)
      q += valueAttribute + "=" + values[i];
    else
      q += " OR " + valueAttribute + "=" + values[i];

  request.queryString = q;
  return request;
        }
id String No the identifier for the component. Every component may be named by a component identifier that must conform to the following rules:
  • They must start with a letter (as defined by the Character.isLetter() method) or underscore ( _ ).
  • Subsequent characters must be letters (as defined by the Character.isLetter() method), digits as defined by the Character.isDigit() method, dashes ( - ), or underscores ( _ ). To minimize the size of responses generated by JavaServer Faces, it is recommended that component identifiers be as short as possible. If a component has been given an identifier, it must be unique in the namespace of the closest ancestor to that component that is a NamingContainer (if any).
partialTriggers String[] Yes the IDs of the components that should trigger a partial update. This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too. Identifiers are relative to the source component (this component), and must account for NamingContainers. If your component is already inside of a naming container, you can use a single colon to start the search from the root of the page, or multiple colons to move up through the NamingContainers - "::" will pop out of the component's naming container (or itself if the component is a naming container) and begin the search from there, ":::" will pop out of two naming containers (including itself if the component is a naming container) and begin the search from there, etc.
rendered boolean Yes Default Value: true

whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component.
type String Yes Default Value: default

The type of the search section. Broadly, there are two types of searchSection that are recognized by af:inputSearch component.
  1. "default": The master suggestions list that the af:inputSearch component will work with. Each inputSearch component must have a default searchSection. The suggestions from default searchSection is displayed only during filtering if af:suggestionsSection or other types of searchSection are also configured.
  2. Other types: A searchSection other than default list is treated as a special suggestion group. Suggestion groups can either have a dataUrl of its own, or can be a client sub-list of default searchSection's data using the filter attribute. In either case, the data of non default searchSection should be a subset of the default searchSection.