com.webmethods.caf.faces.bean.search
Class BaseSearchPageBean

java.lang.Object
  extended by com.webmethods.caf.faces.bean.BaseFacesBean
      extended by com.webmethods.caf.faces.bean.BaseFacesSessionBean
          extended by com.webmethods.caf.faces.bean.BaseViewBean
              extended by com.webmethods.caf.faces.bean.BaseWebPageBean
                  extended by com.webmethods.caf.faces.bean.search.BaseSearchPageBean
All Implemented Interfaces:
IPageFlowScopeAdapter, ISearchBarPageBean, ISearchPageBean, ISearchResultsPageBean

public abstract class BaseSearchPageBean
extends BaseWebPageBean
implements ISearchBarPageBean, ISearchResultsPageBean, ISearchPageBean

Base class for a CAF view that contains both a searchbar and search results table in the same view.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.webmethods.caf.faces.bean.BaseViewBean
BaseViewBean.ClientIdsContentProvider
 
Field Summary
protected  int fPreviousInvocationID
          Holds the search invocation ID for the previous request
protected  boolean fQueryChanged
          indicates if current query has changed and new search is needed
protected  ISavedSearchProvider fSavedSearchProvider
          Reference to the current saved search provider
protected  ISearchOptionsManager fSearchOptionsManager
          Reference to the current search options manager
protected  ISearchQueryFactory fSearchQueryFactory
          Reference to the current search query factory
protected  ISearchResultsOptionsManager fSearchResultsOptionsManager
          Reference to the current search result options manager
protected  List fSortableColumns
          Temporary list of sortable columns
protected  List fViewableColumns
          Temporary list of viewable columns
protected  ISearchQuery resultsSearchQuery
          Holds the active search query for the search results table control
protected static String SEARCH_RESULT_PREFERENCES_APPLIED_KEY
          Attribute name used to flag whether the search result preferences have been applied to the search result table control.
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseViewBean
clientIds, initialized
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
fExpireWithPageFlow
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
DATA_BINDING_CLIENTS, OUTCOME_ERROR, OUTCOME_OK, resourcesProviders
 
Constructor Summary
BaseSearchPageBean()
           
 
Method Summary
static void applyUserPreferences(DataTable dataTable, String[] columnDisplay, String initialSortBy, String columnWidth, boolean initialSortAscending)
          Apply the user preferences to the data table.
protected  void beforeRenderResponse()
          Overrides the default behavior to detect when a search query has changed and apply user preferences to the search result table control before rendering.
protected  ISearchQuery createSearchQuery()
          Creates and returns a new SearchQuery object for the SearchBar control.
 String doSearch()
          Action handler for executing a search
 ISavedSearch getActiveSavedSearch()
          Gets the active saved search object for the SearchBar control.
 ISearchQuery getActiveSearchQuery()
          Gets the active search query object for the SearchBar control.
 String getActiveSearchQueryString()
          Controls may use this method to determine if there is an active query
abstract  UIComponent getActiveSearchResultsControl()
          Return the active search results component (table, tree, whatever).
 String getColumnWidthsPreference()
          Delegates to the same API on the current search result options manager
 String[] getDisplayColumnsPreference()
          Delegates to the same API on the current search result options manager
 int getInitialPageSize()
          Delegates to the same API on the current search result options manager
 Boolean getInitialSortAscendingPreference()
          Delegates to the same API on the current search result options manager
 String getInitialSortByPreference()
          Delegates to the same API on the current search result options manager
 ISearchQuery getResultsSearchQuery()
          Gets the active search query object for the SearchResults control.
protected  SearchBar getSafeSearchBarControl()
          Wrapper around the getSearchBarControl method that throws an exception if the SearchBar value is null
 ISavedSearchProvider getSavedSearchProvider()
          Creates and returns implementation of ISavedSearchProvider
abstract  SearchBar getSearchBarControl()
          Retrieves the SearchBar control for this page
 ISearchOptionsManager getSearchOptionsManager()
          Creates and returns implementation of ISearchOptionsManager
 ISearchQueryFactory getSearchQueryFactory()
          Creates and returns implementation of ISearchQueryFactory
 ISearchResultsOptionsManager getSearchResultsOptionsManager()
          Gets the search results options manager
 List getSortableColumnList()
          Returns the list of sortable columns
 List getViewableColumnList()
          Returns the list of viewable columns
 boolean isQueryChanged()
          Returns whether the query has changed from the previous request
 boolean isSearchBarOnAdvancedTab()
          Returns true if the active searchbar tab is the the 'Advanced' tab
 boolean isSearchBarOnOptionsTab()
          Returns true if the active searchbar tab is the the 'Options' tab
 boolean isSearchBarOnSavedTab()
          Returns true if the active searchbar tab is the the 'Saved' tab
 boolean isSearchBarOnSimpleTab()
          Returns true if the active searchbar tab is the the 'Search' tab
static void loadColumnInfoForControl(DataTable dataTable, List viewableColumnList, List sortableColumnList)
          Loads the column info for the requested control
 void loadSearchQueryDefaults(ISearchQuery query)
          Page bean may load default values into search query object
 String persistDisplayOptions()
          Action handler for the drag-to-resize/reorder-columns updates.
 void setColumnWidthsPreference(String columnWidths)
          Delegates to the same API on the current search result options manager
 void setDisplayColumnsPreference(String[] columnDisplay)
          Delegates to the same API on the current search result options manager
 void setInitialPageSize(int pageSize)
          Delegates to the same API on the current search result options manager
 void setInitialSortAscendingPreference(Boolean ascending)
          Delegates to the same API on the current search result options manager
 void setInitialSortByPreference(String sortBy)
          Delegates to the same API on the current search result options manager
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseWebPageBean
getAppNavBean
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseViewBean
afterApplyRequestValues, afterInvokeApplication, afterPhase, afterProcessValidations, afterRenderResponse, afterRestoreView, afterUpdateModelValues, beforeApplyRequestValues, beforeInvokeApplication, beforePhase, beforeProcessValidations, beforeRestoreView, beforeUpdateModelValues, callInitialize, findComponent, findComponentInRoot, getApplicationScope, getClientIds, getPhaseId, getRealPath, getRequestParam, getRequestScope, getSessionScope, gotoPage, gotoPage, initialize, isAsyncRequest, release, resetPageFlowStorage, streamFileDataToResponse
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
getExpireWithPageFlow, setExpireWithPageFlow, valueBound, valueUnbound
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
createMethodBinding, createValueBinding, error, error, error, error, error, getBean, getFacesContext, getLocale, getResourceInputStream, getResources, getResourcesProvider, getRootCause, getStackTrace, getTreeAttribute, isUserInRole, log, log, log, putTreeAttribute, resetDataBindingClients, resolveDataBinding, resolveDataBinding, resolveExpression, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEARCH_RESULT_PREFERENCES_APPLIED_KEY

protected static final String SEARCH_RESULT_PREFERENCES_APPLIED_KEY
Attribute name used to flag whether the search result preferences have been applied to the search result table control.

See Also:
Constant Field Values

fSavedSearchProvider

protected transient ISavedSearchProvider fSavedSearchProvider
Reference to the current saved search provider


fSearchQueryFactory

protected transient ISearchQueryFactory fSearchQueryFactory
Reference to the current search query factory


fSearchOptionsManager

protected transient ISearchOptionsManager fSearchOptionsManager
Reference to the current search options manager


fSearchResultsOptionsManager

protected transient ISearchResultsOptionsManager fSearchResultsOptionsManager
Reference to the current search result options manager


fViewableColumns

protected transient List fViewableColumns
Temporary list of viewable columns


fSortableColumns

protected transient List fSortableColumns
Temporary list of sortable columns


fPreviousInvocationID

protected int fPreviousInvocationID
Holds the search invocation ID for the previous request


fQueryChanged

protected boolean fQueryChanged
indicates if current query has changed and new search is needed


resultsSearchQuery

protected ISearchQuery resultsSearchQuery
Holds the active search query for the search results table control

Constructor Detail

BaseSearchPageBean

public BaseSearchPageBean()
Method Detail

getSearchResultsOptionsManager

public ISearchResultsOptionsManager getSearchResultsOptionsManager()
Gets the search results options manager

Returns:
searh results options manager

getSavedSearchProvider

public ISavedSearchProvider getSavedSearchProvider()
Description copied from interface: ISearchBarPageBean
Creates and returns implementation of ISavedSearchProvider

Specified by:
getSavedSearchProvider in interface ISearchBarPageBean

getSearchOptionsManager

public ISearchOptionsManager getSearchOptionsManager()
Description copied from interface: ISearchBarPageBean
Creates and returns implementation of ISearchOptionsManager

Specified by:
getSearchOptionsManager in interface ISearchBarPageBean

getSearchQueryFactory

public ISearchQueryFactory getSearchQueryFactory()
Description copied from interface: ISearchBarPageBean
Creates and returns implementation of ISearchQueryFactory

Specified by:
getSearchQueryFactory in interface ISearchBarPageBean

loadSearchQueryDefaults

public void loadSearchQueryDefaults(ISearchQuery query)
Description copied from interface: ISearchBarPageBean
Page bean may load default values into search query object

Specified by:
loadSearchQueryDefaults in interface ISearchBarPageBean

persistDisplayOptions

public String persistDisplayOptions()
                             throws Exception
Description copied from interface: ISearchResultsPageBean
Action handler for the drag-to-resize/reorder-columns updates. By default, it will persist the search results options via the portlet's preference beans' storePreferences() method.

Specified by:
persistDisplayOptions in interface ISearchResultsPageBean
Returns:
status of the action handler
Throws:
Exception

getActiveSearchQueryString

public String getActiveSearchQueryString()
Controls may use this method to determine if there is an active query

Returns:
empty string if there is not an active query, or "non-empty" if there is an active query

isSearchBarOnSimpleTab

public boolean isSearchBarOnSimpleTab()
Returns true if the active searchbar tab is the the 'Search' tab

Returns:
true if the active searchbar tab is the 'Search' tab

isSearchBarOnAdvancedTab

public boolean isSearchBarOnAdvancedTab()
Returns true if the active searchbar tab is the the 'Advanced' tab

Returns:
true if the active searchbar tab is the 'Advanced' tab

isSearchBarOnOptionsTab

public boolean isSearchBarOnOptionsTab()
Returns true if the active searchbar tab is the the 'Options' tab

Returns:
true if the active searchbar tab is the 'Options' tab

isSearchBarOnSavedTab

public boolean isSearchBarOnSavedTab()
Returns true if the active searchbar tab is the the 'Saved' tab

Returns:
true if the active searchbar tab is the 'Saved' tab

getSearchBarControl

public abstract SearchBar getSearchBarControl()
Retrieves the SearchBar control for this page

Returns:
SearchBar control for the page

getActiveSearchResultsControl

public abstract UIComponent getActiveSearchResultsControl()
Return the active search results component (table, tree, whatever).

Returns:
active search results component

getSafeSearchBarControl

protected SearchBar getSafeSearchBarControl()
Wrapper around the getSearchBarControl method that throws an exception if the SearchBar value is null

Returns:
SearchBar control for the page

getActiveSearchQuery

public ISearchQuery getActiveSearchQuery()
Gets the active search query object for the SearchBar control.

Specified by:
getActiveSearchQuery in interface ISearchPageBean
Returns:
Returns the activeSearchQuery.

getResultsSearchQuery

public ISearchQuery getResultsSearchQuery()
Gets the active search query object for the SearchResults control.

Returns:
Returns the resultsSearchQuery.

getActiveSavedSearch

public ISavedSearch getActiveSavedSearch()
Gets the active saved search object for the SearchBar control.

Returns:
Returns the activeSavedSearch.

createSearchQuery

protected ISearchQuery createSearchQuery()
Creates and returns a new SearchQuery object for the SearchBar control. Sub-classes may override to provide an alternate ISearchQuery implementation.

Returns:
Returns a new ISearchQuery object

beforeRenderResponse

protected void beforeRenderResponse()
Overrides the default behavior to detect when a search query has changed and apply user preferences to the search result table control before rendering.

Overrides:
beforeRenderResponse in class BaseViewBean
See Also:
BaseViewBean.beforeRenderResponse()

isQueryChanged

public boolean isQueryChanged()
Returns whether the query has changed from the previous request

Returns:
true if the query has changed, false otherwise

getDisplayColumnsPreference

public String[] getDisplayColumnsPreference()
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.getDisplayColumnsPreference()

setDisplayColumnsPreference

public void setDisplayColumnsPreference(String[] columnDisplay)
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.setDisplayColumnsPreference(String[])

getInitialPageSize

public int getInitialPageSize()
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.getInitialPageSize()

setInitialPageSize

public void setInitialPageSize(int pageSize)
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.setInitialPageSize(int)

getColumnWidthsPreference

public String getColumnWidthsPreference()
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.getColumnWidthsPreference()

setColumnWidthsPreference

public void setColumnWidthsPreference(String columnWidths)
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.setColumnWidthsPreference(String)

getInitialSortByPreference

public String getInitialSortByPreference()
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.getInitialSortByPreference()

setInitialSortByPreference

public void setInitialSortByPreference(String sortBy)
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.setInitialSortByPreference(String)

getInitialSortAscendingPreference

public Boolean getInitialSortAscendingPreference()
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.getInitialSortAscendingPreference()

setInitialSortAscendingPreference

public void setInitialSortAscendingPreference(Boolean ascending)
Delegates to the same API on the current search result options manager

See Also:
ISearchResultsOptionsManager.setInitialSortAscendingPreference(boolean)

getSortableColumnList

public List getSortableColumnList()
Returns the list of sortable columns

Returns:
list of sortable columns

getViewableColumnList

public List getViewableColumnList()
Returns the list of viewable columns

Returns:
list of viewable columns

loadColumnInfoForControl

public static void loadColumnInfoForControl(DataTable dataTable,
                                            List viewableColumnList,
                                            List sortableColumnList)
Loads the column info for the requested control

Parameters:
viewableColumnList - list where the viewable columns are added
sortableColumnList - list where the sortable columns are added

applyUserPreferences

public static void applyUserPreferences(DataTable dataTable,
                                        String[] columnDisplay,
                                        String initialSortBy,
                                        String columnWidth,
                                        boolean initialSortAscending)
Apply the user preferences to the data table.

Parameters:
dataTable - the search result table control
columnDisplay - array of columns to display
initialSortBy - column id to sort by
columnWidth - widths of the displayed columns
initialSortAscending - sort order

doSearch

public String doSearch()
Action handler for executing a search

Returns:
outcome of the actions