Class CmsHookListSearchCategory

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.Deque<java.lang.String>, java.util.List<java.lang.String>, java.util.Queue<java.lang.String>

    public class CmsHookListSearchCategory
    extends CmsHookList
    A hook on the list of categories of the CmsSearchParameters (see CmsSearchParameters.setCategories(List)) that will set the page to display of the search parameters to start (1) whenever a change in the amount of categories takes place.

    This hook monitors the actions of the CmsWidgetDialog: During a request - response cycle it clears the list (prepareCommit) of categories and adds all request parameters (actionCommitValue) to the list.

    The strategy here is to save all categories in a backup at "onClear" - time and then wait until all add operations are finished. This is when the iterator() method is triggered by the running search (CmsSearch.getSearchResult()). At that time it is detected wether we have "lost" categories. If this is the case, the search page will be reset to start.

    Warning

    This procedure is highly unstable as coupled to the behaviour of CmsWidgetDialog. It will only be successful if the request parameter "action" has a value in
    1. CmsWidgetDialog.DIALOG_SAVE
    2. CmsDialog.DIALOG_BACK
    3. CmsDialog.DIALOG_CONTINUE
    Search page links (CmsSearch.getPageLinks()) contain a parameter "action" with value "search" which has to be rewritten to one of those values or the order of operations on widget - managed collections does not work together with the detection strategy for category changes used here.

    Since:
    6.0.0
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsHookListSearchCategory​(org.opencms.search.CmsSearchParameters peer)  
      CmsHookListSearchCategory​(org.opencms.search.CmsSearchParameters peer, java.util.Collection<java.lang.String> c)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void onAdded​(java.lang.Object peer, int index, java.lang.Object element)
      A category has been added: do nothing.
      protected void onAdded​(java.lang.Object peer, java.lang.Object added)
      React on the performed operation List.add(java.lang.Object) by informing argument peer.
      protected void onClear​(java.lang.Object peer)
      Takes a copy of the current categories contained to a backup list as this operation is triggered by CmsWidgetDialog.ACTION_SAVE.
      protected void onCleared​(java.lang.Object peer)
      React on the performed operation List.clear() by informing argument peer.
      protected void onGetCall​(java.lang.Object peer, int index)
      Set the search page of the peer Object (CmsSearch.setSearchPage(int)) to zero if the internal backup list of categories (taken at clear time which is triggered by CmsWidgetDialog.ACTION_SAVE) was empty (no restriction) and now categories are contained or if the new backup list of categories is no subset of the current categories any more (more restrictive search than before).
      protected void onIteratorCall​(java.lang.Object peer)
      React on the performed operation List.iterator() by informing argument peer.
      protected void onRemoved​(java.lang.Object peer, int index)
      A category has been removed: set search page to start page as new results may / will be smaller.
      • Methods inherited from class java.util.LinkedList

        addAll, addAll, addFirst, addLast, clone, contains, descendingIterator, element, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, removeAll, retainAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode, isEmpty, listIterator, removeAll, replaceAll, retainAll, sort, subList
    • Constructor Detail

      • CmsHookListSearchCategory

        public CmsHookListSearchCategory​(org.opencms.search.CmsSearchParameters peer)
        Parameters:
        peer - the search parameters to modify upon category modifications.
      • CmsHookListSearchCategory

        public CmsHookListSearchCategory​(org.opencms.search.CmsSearchParameters peer,
                                         java.util.Collection<java.lang.String> c)
        Parameters:
        peer - the search parameters to modify upon category modifications
        c - a collection with all values for this list
    • Method Detail

      • onAdded

        protected void onAdded​(java.lang.Object peer,
                               int index,
                               java.lang.Object element)
        A category has been added: do nothing.

        Specified by:
        onAdded in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index the element was added at
        element - the element that was added
        See Also:
        CmsHookList.onAdded(java.lang.Object, int, java.lang.Object)
      • onAdded

        protected void onAdded​(java.lang.Object peer,
                               java.lang.Object added)
        Description copied from class: CmsHookList
        React on the performed operation List.add(java.lang.Object) by informing argument peer.

        Specified by:
        onAdded in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        added - the element that was successfully added
        See Also:
        CmsHookList.onAdded(java.lang.Object, java.lang.Object)
      • onCleared

        protected void onCleared​(java.lang.Object peer)
        Description copied from class: CmsHookList
        React on the performed operation List.clear() by informing argument peer.

        This is called after the actual clear operation has taken place.

        Specified by:
        onCleared in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        See Also:
        CmsHookList.onCleared(java.lang.Object)
      • onGetCall

        protected void onGetCall​(java.lang.Object peer,
                                 int index)
        Set the search page of the peer Object (CmsSearch.setSearchPage(int)) to zero if the internal backup list of categories (taken at clear time which is triggered by CmsWidgetDialog.ACTION_SAVE) was empty (no restriction) and now categories are contained or if the new backup list of categories is no subset of the current categories any more (more restrictive search than before).

        Specified by:
        onGetCall in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index of the Object to get
        See Also:
        CmsHookList.onGetCall(java.lang.Object, int)
      • onIteratorCall

        protected void onIteratorCall​(java.lang.Object peer)
        Description copied from class: CmsHookList
        React on the performed operation List.iterator() by informing argument peer.

        Note that the iterator is only obtained but not given to the requesting client when this handler is invoked.

        Specified by:
        onIteratorCall in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        See Also:
        CmsHookList.onIteratorCall(java.lang.Object)
      • onRemoved

        protected void onRemoved​(java.lang.Object peer,
                                 int index)
        A category has been removed: set search page to start page as new results may / will be smaller.

        Specified by:
        onRemoved in class CmsHookList
        Parameters:
        peer - the object reactions on operations shall be made on in this "listlet" method
        index - the index where the value has been removed
        See Also:
        CmsHookList.onRemoved(java.lang.Object, int)