Getting the value of Saved search in programatic way

This code can be added to the setter of the component from where you want to access the saved search of the af:query panel

QueryModel qm = (QueryModel)evaluateEL("#{bindings.<searchRegionFromThePageDef>.queryModel}");
for(int indexCount=0; indexCount<qm.getUserQueries().size();indexCount++)
 QueryDescriptor qd = qm.getUserQueries().get(indexCount);
 String queryDescriptorName = qd.getName();
 m = qd.getUIHints();
 isDefault = (Boolean) m.get(QueryDescriptor.UIHINT_DEFAULT);
 isRunAutomatically = (Boolean) m.get(QueryDescriptor.UIHINT_AUTO_EXECUTE);

 if (Boolean.TRUE.equals(isDefault) && Boolean.TRUE.equals(isRunAutomatically){
 //code goes here
 //else code

quick walk through..

  • Getting the handle to QueryModel
  • Iterating through the userQueries. ie. the Saved Searches
  • Get handle to the QueryDescriptor
  • get handle to UIHints from the QueryDescriptor
  • check for QueryDescriptor.UIHINT_DEFAULT and QueryDescriptor.UIHINT_AUTO_EXECUTE and implement the logic based on the value obtained.

1 thought on “Getting the value of Saved search in programatic way

  1. Darshan Kumar

    Hi, is there a way to enable site level Saved Search.
    for ex: In a company if there are 10 users say user_1 , user_2, user_3, now if user_1 creates a saved search, that particular saved search should be seen by all other users i.e. user_2, user_3 .

    Is there a way to achieve this ?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s