Save and Retrieve Search Queries

The Appkit Social Module lets users save and retrieve their search queries. Use the Saved Query Form tag to let users save search queries. Use the Saved Query List tag to let users retrieve their saved search queries.

Saved Query Form tag

The Saved Query Form Tag displays controls for storing the current search query.


The Saved Query Form Tag is placed on a page to allow the authenticated user to store a reference to the current search query, under a give name:

<social:savedQueryForm name="${search:hasDisplayValue(query.value) ? query.value.display : 'My saved search'}" query="${query}" />

Required Tag Attributes

query (twigkit.model.Query)
The search query that should be stored.

Optional Tag Attributes

name (java.lang.String)
Default name for a query.
Default: ""

topic (twigkit.model.Topic)
A topic to which the saved query should belong.

legend (java.lang.String)
Legend for the form.
Default: "Saved Searches"

buttonLabel (java.lang.String)
Label of form submit button.
Default: "Save"

inputLabel (java.lang.String)
Label of form input box for the query name.
Default: "Name"

placeholder (java.lang.String)
Placeholder value to put in the query name text box.
Default: "Type a name for the current search query…"

Saved Query List tag

The Saved Query List tag retrieves and displays all the search queries that have been stored by a particular user.


The Saved Query List tag is typically used as follows:

<social:savedQueryList user="${social:getCurrentUserProfile()}" emptyText="You don't currently have any saved searches." />

Tag Attributes

user (twigkit.model.UserProfile)
Specifies the user whose queries should be retrieved.

topic (twigkit.model.Topic)
Optionally, saved queries can be scoped to a particular topic. If this attribute is set, then the tag will list only those queries that are linked to that topic.

format (java.lang.String)
Which date format to use.
Default: "relative"

deleteLabel (java.lang.String)
Label to display for the delete action.
Default: "x"

show (java.lang.Integer)
How many queries should be displayed initially.
Default: 5

showMore (java.lang.Integer)
How many more queries should be added to the list each time the user clicks 'Show more'.
Default: 10

showMoreLabel (java.lang.String)
Label to display for 'show more' action.
Default: "Show more"

showLessLabel (java.lang.String)
Label to display for 'show fewer' action.
Default: "Show fewer"

emptyText (java.lang.String)
Text to display if the the user has not saved any queries.
Default: ""

action (java.lang.String)
Path to prefix all query URLs with, e.g. "/mysearch".
Default: ""

JSP expressions

These Social Module methods are useful for working with saved queries. They are accessible through JSP Expression Language (EL) expressions. Sample expressions are shown. getPublicTopicByPath(java.lang.String topicPath)
Finds and returns the public topic with the given path.
${social:getPublicTopicByPath('myTopic')} getPublicTopicByPathAutoCreate(java.lang.String topicPath)
Finds and returns the public topic with the given path, creating a new topic if one does not already exist.
${social:getPublicTopicByPathAutoCreate('myTopic')} getPrivateTopicByPath(java.lang.String topicPath, profile)
Finds and returns the topic that belongs to a specific user.
${social:getPrivateTopicByPath('myTopic', social:getCurrentUserProfile())}

For example, a saved query can be associated with a particular topic:

<social:savedQueryForm query="${myquery}" topic="${social:getPublicTopicByPathAutoCreate('myTopic')}" />

When the list of saved queries is displayed, the list is restricted to that particular topic:

<social:savedQueryList topic="${social:getPublicTopicByPath('myTopic')}" />