The search feed can return different kinds of values for a given meta, and you may want to display these values with specific look and feels in the search hits.
For example, you can have several types of documents - for example an MS Word document, an intranet page, etc. - and you want to associate each type to a specific look and feel in the search hits. In this case, you can customize the display of hits by types conditionally, by creating your own JSP files and referencing them as described in the following procedures.
Note: To customize the look-and-feel, the JSP files can either include specific HTML codes or reference CSS files.
Conditionally display hits with the Result List widget
1. In Mashup Builder, go to the /search page and select the Design view.
2. Click the header of the Result List widget.
3. On the widget properties panel, go to the Hit templates tab.
4. In the Hit JSP template field:
a. Enter the relative or the absolute path to the directory containing your custom JSP.
b. Use a dynamic hit meta in your path to add a condition on the document type.
For example: mytemplate/${entry.metas["type"]}.jsp
c. The dynamic value will apply a specific JSP template for each type of document that has its own dedicated JSP. The default template is applied otherwise. For example, let’s say that you have created the following JSP templates: filesystem.jsp, intranet.jsp, mail.jsp, etc.
5. Select the Preview to check your configuration changes.
6. Click Apply.
Conditionally display hits with the For Each Hit widget
1. In Mashup Builder, go to the /search page and select the Design view.
2. In the Widgets panel, expand the Miscellaneous category and drag a For Each Hit widget on the workspace.
3. In the Widgets panel, expand the HTML category, and drag the HTML widget within the For Each Hit widget.
4. On the widget properties panel, in the Advanced > JSP file path field:
a. Enter the absolute path to the directory containing your custom JSPs.
b. To add a condition on the document type, use a dynamic hit meta in the path. For example: /WEB-INF/jsp/${entry.metas["type"]}.jsp
c. The dynamic value will apply a specific JSP template for each type of document that has its own dedicated JSP. The default template is applied otherwise.
For example, let’s say that you have created the following JSP templates: filesystem.jsp, intranet.jsp, mail.jsp, etc.
5. Select the Preview to check your configuration changes.