Search Request View Plugin Module
Search Request View plugin modules are available in JIRA 3.7 and later.
Search request view plugin modules are used to display different representations of search results in the issue navigator. They will be displayed as a link at the top of the issue navigator. Once clicked, JIRA will render the search request view.
Here's what the bundled 'Printable' view looks like:
Search request views can be used to render the search results in any possible representation. Some popuplar choices are for example RSS or XML.
On this page:
The Search Request View Plugin Module
A search request view plugin consists of 3 components:
- The plugin module definition in
- The view implementation class defining any logic needed to render a view
- Any number of view templates defining how to render the view.
Let's attempt a sample implementation, to render the results of a search request in this format:
Plugin Module Definition
First a definition of the plugin is needed in your plugin's atlassian-plugin.xml:
The search-request-view module is fairly straight-forward. It defines a unique key for the module, a name which will be used for the link in the issue navigator and the view implementation class. Further it also defines what contentType to return when displaying this view and a number of view resources. Finally the order can be used to control in which order the links appear in the IssueNavigator.
Search Request View Implementation Class
The view implementation class below extends a convenience class available in JIRA to make writing search request views easier, namely AbstractSearchRequestView. All that's left to do then is to implement the
If a search request view needs more control (e.g. control the HTTP headers used in the returned view), then an implementation class can implement the SearchRequestView interface directly.
Finally, a number of view templates are needed to display our new view.
First, the header needs to display the filtername as an attribute of the
<issues> tag or simply 'Anonymous' if the view isn't displaying a saved filter:
Then to render each issue, we need to construct an
<issue> tag for each individual issue:
Finally the footer should close the
Limiting the number of search results shown
While JIRA provides an application property to limit the number of issues returned from its built-in search request views (see Limiting the number of issues returned from a search view such as an RSS feed), this limit is not automatically applied to plugin search views accessed from the issue navigator.
For JIRA 4.3.0 and later:
You can get the value of this property using the getMaxResults() method of the
IssueSearchLimits interface, after this interface has been injected into your constructor. For example:
For JIRA 4.2.x and earlier:
Use the getDefaultBackedString() method of the
ApplicationProperties interface to obtain the JIRA_SEARCH_VIEWS_DEFAULT_MAX property of the
APKeys interface, after the
ApplicationProperties interface has been injected into your constructor.
Here's what the sample plugin looks like in action:
And this is a sample search result rendered by the plugin: