Linking directly to search queries
Haven't you wondered how we can link to a query from a template or JSP from a custom page or plugin page? In this recipe, we will see how we can create a link programmatically and otherwise to use in various places.
How to do it...
Let us first look at creating a search link programmatically. Perform the following steps:
Create the
Query
object usingJqlQueryBuilder
, as we have seen in the previous recipe.Get an instance of the
SearchService
. It could be injected in the constructor of your plugin using dependency injection or can be retrieved from theComponentManager
class as follows:SearchService searchService = ComponentManager.getInstance().getSearchService();
Retrieve the query string from the
Query
object usingSearchService
, as shown:String queryString = searchService.getQueryString(user, query);
Construct the link using the context path. In JSPs, you can do it as shown next:
<a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa...