Tag Archives: search

Webcenter Services at a glance


AnalyticsGoogle Analytics – shows analytics for the personal site

AnnouncementsGoogle calendar announcement about the birthdays and anniversary

BlogBlogspot for blogging

DiscussionsForums to discuss anything

DocumentsGoogle Docs for content management

EventsGoogle calendar to mark events

Instant Messaging and PresenceGtalk for messaging

LinksGoogle bookmarks for storing links

ListsListing of ongoing/pending tasks

MailGMail

NotesGoogle Notes

NotificationsFacebook posting on walls

People connectionsFacebook

PollsFacebook polling for suggestions

PersonalizationsiGoogle to personalize home page

Recent ActivitiesFacebook activities

Activity GraphGoogle site statistics

RSSBlog feed for updates

SearchGoogle search

TagsPicasa photo tags

WikiWikipedia for informations

WorkListstodo lists for daily Agenda

Advertisements

Getting the value of Saved search – programatic way


QueryModel qm = (QueryModel)evaluateEL("#{bindings.SearchViewCriteriaQuery.queryModel}");
 for(int indexCount=0; indexCount
 {
 QueryDescriptor qd = qm.getUserQueries().get(indexCount);
 if(qd!=null){
 String queryDescriptorName = qd.getName();
 System.out.println(queryDesctiptorName);
 m = qd.getUIHints();
 isDefault = (Boolean) m.get(QueryDescriptor.UIHINT_DEFAULT);
 System.out.println(isDefault);
 isRunAutomatically = (Boolean) m.get(QueryDescriptor.UIHINT_AUTO_EXECUTE);
 System.out.println(isRunAutomatically);
 if (Boolean.TRUE.equals(isDefault) && Boolean.TRUE.equals(isRunAutomatically){
 break();
 }
 else{
 queryDescriptorName = null;
 }
 System.out.println(isDefault);
 }

Ways to set the Query Mode programatically


The following snippet will be helpful in setting up the mode of the query criteria in programmatic way.

public Boolean setAdvancedMode(){
              QueryDescriptor descriptor =
                      (QueryDescriptor)evaluateEL
                  ("#{bindings.SearchCriteriaQuery.queryDescriptor}");
              descriptor.changeMode(QueryDescriptor.QueryMode.ADVANCED);
             return true;
}

public Object evaluateEL(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =
            facesContext.getApplication().getExpressionFactory();
        ValueExpression exp =
            expressionFactory.createValueExpression(elContext, el,
                                                    Object.class);
       return exp.getValue(elContext);
    }

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);
 if(qd!=null){
 String queryDescriptorName = qd.getName();
 System.out.println(queryDesctiptorName);
 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{
 //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.