Support and Documentation


Leveraging the SearchResultSelectionGeneratable annotation, you can create a complex Content type with a search result action. For example, you can have a MultiMediaGallery type that consists of Image and Video slides. A query for Image or Video types displays an associated action in the search panel. Invoking the action creates a MultiMediaGallery object with any Image or Video objects selected in the search results.

The following steps show how to construct a search result action that creates a MultiMediaGallery content type.

Step 1: Create the content type

@SearchResultSelectionGeneratable.ItemTypes({Image.class, Video.class}) 1
public class MultiMediaGallery extends Content {

   private List<Slide> slides; 2
   public List<Slide> getSlides() { return slides; }
   public void setSlides(List<Slide> slides) { this.slides = slides; }

   private static abstract class Slide extends Record { } 3

   private static class ImageSlide extends Slide { 4
      private Image image;

      public Image getImage() {
         return image;

      public void setImage(Image image) {
         this.image = image;

   private static class VideoSlide extends Slide { 5
      private Video video;

      public Video getVideo() {
         return video;

      public void setVideo(Video video) { = video;

   public void fromSelection(SearchResultSelection selection) { 6

      for (Object object : selection.createItemsQuery().selectAll()) {
         if (object instanceof Image) {
             // If the selected object is an Image, create a new ImageSlide to wrap it.
             ImageSlide imageSlide = new ImageSlide();
             imageSlide.setImage((Image) object);

         } else if (object instanceof Video) {
             // If the selected object is a Video, create a new VideoSlide to wrap it.
             VideoSlide videoSlide = new VideoSlide();
             videoSlide.setVideo((Video) object);
         // Ignore any other objects that are not Images or Videos


Class annotation that enables MultiMediaGallery objects to be created from Image and Video objects returned in search results.


Defines a list for a Slide type and associated getter and setter methods.


Embeds an abstract Slide class.


Implements an ImageSlide inner class for slides consisting of Image objects.


Implements a VideoSlide inner class for slides consisting of Video objects.


Implements the fromSelection method from the SearchResultSelectionGeneratable interface. The method creates Image or Video slides from the SearchResultSelection object. After usage of the SearchResultSelection to create a new Content instance, the SearchResultSelection is destroyed.

Step 2: Implement SearchResultAction

The SearchResultAction implementation displays the applicable action button in the search panel.

public class MultiMediaGalleryAction implements SearchResultAction {

   public int getPosition() {
      return 0;

   public boolean shouldDisplay(ToolPageContext page, Search search, SearchResultSelection selection) {
      return true;

   // @Override
   public void writeHtml(
      ToolPageContext page,
      Search search,
      SearchResultSelection selection)
      throws IOException {

      if (selection == null) { 1

      page.writeStart("div", "class", "searchResult-action-simple");

             "class", "button",
             "target", "toolUserMultiMedia",
             "href", new UrlBuilder(page.getRequest())  2
                     .absolutePath(page.toolPath(CmsTool.class, "toolUserMultiMedia"))
                     .parameter("selectionId", selection.getId()));
      page.writeHtml(page.localize(MultiMediaGalleryAction.class, 3"action.MultiMediaGalleryAction"));


Checks for search results that are selected in the UI. If there are no selections, then the implementation does not display the action button.


Constructs the URL to the page servlet, specified in the servlet routing path as toolUserMultiMedia. Only one parameter is passed to the servlet, selectionId, returned by the SearchResultSelection#getId() method.


Specifies the label on the action button. The label is retrieved from a localization resource file.

When results are selected in the search panel, the Create MultiMediaGallery button appears.


Step 3: Implement page servlet

The page servlet invoked from the search result action creates the MultiMediaGallery objects from the search result selections.

@RoutingFilter.Path(application = "cms", value = "toolUserMultiMedia") 1
public class ToolUserMultiMedia extends PageServlet {

   protected String getPermissionId() {
      return null;

   protected void doService(ToolPageContext page) throws IOException, ServletException {

      UUID selectionId = page.param(UUID.class, "selectionId"); 2
      SearchResultSelection selection = Query.from(SearchResultSelection.class).where("_id = ?", selectionId).first(); 3 

      MultiMediaGallery gallery = new MultiMediaGallery(); 4


Specifies the annotation @RoutingFilter.Path of the servlet as toolUserMultiMedia.


Gets the value of the selectionId parameter passed from MultiMediaGalleryAction.


Performs a query to get the SearchResultSelection object identified by selectionId.


Creates a MultiMediaGallery object. The SearchResultSelection object can represent selections of various content types. However, MultiMediaGallery is limited to Image and Video item types, so the implemented fromSelection method creates gallery slides from only those types.