public class SavedSearches extends DataClass
ListGrid
or TileGrid
may allow users to set up their own search criteria within an application,
either via an external SearchForm
, or through built in UI such as the ListGrid.filterEditor
. The "Saved Search" subsystem allows users to save out their criteria (and in some cases user-configured view state) so when the application is reloaded they can easily restore a search or view from a previous session.
Note: The SavedSearches feature requires Smart GWT Pro or better.
User interface components for storing and retreiving saved searches are available via the built in ListGrid features
ListGrid.canSaveSearches
and ListGrid.savedSearchStoredState
, as well as the
explicit the SavedSearchForm and SavedSearchItem
classes.
SavedSearches
is a "singleton" class that provides central handling of storing and
loading saved search data. You acquire the SavedSearches
singleton via get()
and you can configure defaults via Class.addProperties() or
Class.changeDefaults().
Saved searches are stored serialized as JSON
in
DataSource
Records.
By default saved searches are stored in HTML5 browser
localStorage via automatically generated custom DataSources. In this mode the searches are only retained for a
specific user on a particular machine, and searches cannot be shared with other users - but this approach is sufficient
for many applications, works out of the box, does not require any storage and has no impact on scalability.
For more
capable saved search storage and retrieval, an explicit saved search dataSource backed by permanent storage such as an
SQL database table may be specified.
Typically this is done by setting up the defaultDataSource
. This will store searches for all users
and for every component and the same dataSource may even be used for multiple applications.
For finer grained
control, individual saved search dataSources may also be specified per component
.
See getSavedSearchDataSource()
for how to retrieve the
dataSource for a component.
A SavedSearch dataSource has the following fields, some of which are optional, all of which can be renamed as needed. (Click the links to see the purpose of each field):
"pk"
(primary key field, typically of type "sequence") "data"
"searchName"
"componentId"
"projectId"
"screenId"
"applicationId"
"userId"
"admin"
See "Admin-Configured Shared Searches" below. "isDefault"
, See "Default Searches" below. "isSharedDefault"
, See "Default Searches" below.
In your SDK, look for sc_SavedSearches.ds.xml
for a sample SQL-based implementation of saved-search
(entirely declarative). Note that DataSource.cacheAllData
is set to true - this causes all searches applicable to a given user to be loaded in advance, the first time any
component requests saved searches. For most applications, this is the right approach, and is much better than
performing server requests each time a new component is shown that might have saved searches.
Note that the
SavedSearches system can be used to store any kind of component setting; in particular, ListGrids
used SavedSearches
to store
complete viewState
, which includes field order &
visibility, sorting and group state in addition to search criteria.
Shared searches (also referred to as "Admin Searches") are special searches that appear for all
users, as pre-configured default saved searches. While any user can create and edit their own personal saved searches,
admin searches can only be created or edited by users with the adminRole
(see below).
Admin searches are not available when no dataSource was configured to store the savedSearch data. In this case a user's searches are stored to their machine rather than in a central database, and the concept of sharing admin-created searches does not apply.
Admin searches
are identified by either having the userIdField
null, or
by the separate boolean adminField
set to true.
UI
components such as SavedSearchItem
will offer a UI for adding, editing
and removing admin searches if the user has the adminRole
,
as determined by Authentication.hasRole()
.
In addition to
this, for security reasons the server should also enforce role-based authentication for creating and editing admin
searches.
Note: the sample sc_SavedSearches.ds.xml
dataSource has no "admin" field to identify shared
or "admin" searches. Instead records in this dataSource with "userId" set to null are considered to be shared
searches.
The ownerIdField
, ownerIdNullAccess
and ownerIdNullRole
attributes
enforce the appropriate restrictions for editing admin searches -- these settings allow all users to view records with
userId:null
but only users with the "admin" role may create or edit them.
Default searches are searches which will be automatically applied to a component on draw. The SavedSearch subsystem supports two notions of "default" searches. A user may select their personal default search, in which case the next time they load the page this search will be applied to the component automatically. Or an administrator may mark a shared admin search as the default for all users. In this case anyone who loads the application will see this search applied.
If a user has a stored personal default search preference, this always takes precedence over any admin-default search.
Like any admin-searches, admin-default searches only apply when a dataSource was configured to store the savedSearch data.
saveDefaultSearchToServer
is false (the default),
the user-default search preference will be stored in browser localStorage
.
If you want to persist default searches chosen by the user to permanent storage on the server, you can set saveDefaultSearchToServer
to true. In this case the
SavedSearch dataSource must include a boolean defaultField
. Typically this will need to be populated via custom server logic when fetching records to indicate that
the record in question is the chosen default for the current user. When saveDefaultSearchToServer
is true,
the client will issue a custom update operation when the user wants to modify their default search - see setDefaultUserSearchOperation
.
Admin default
searches are stored on the server regardless of whether saveDefaultSearchToServer
is true. The dataSource
should include a boolean adminDefaultField
to
indicate that an admin search record is the shared-default search.
If an admin user updates a record to be the new
shared default search, the client will issue a different custom update operation - see setDefaultAdminSearchOperation
.
Note that
we'd recommend marking this operation as requiresRole="admin"
on the server, as in the sample
sc_SharedSearches.ds.xml
dataSource configuration.
Stored saved search records will have the componentId
field set to the identifier
returned by getSavedSearchId()
for a component. By
default this method returns an identifer based on the a local ID
and DataSource ID
. This means that if you assign a
unique ID to a component that saves searches, and don't change that ID, stored saved searches will always be associated
with the component and its current DataSource.
If you don't set a unique global ID on the component, and your
component isn't part of a Reify screen, and so doesn't have a separate local ID
, the default saved search identifier is not guaranteed to be
consistent across changes to your app, and in that case, previously stored searches will no longer be associated with
the component.
Alternatively you can bypass the ID
dependency
altogether and define an explicit DataBoundComponent.savedSearchId
. This allows you to define a stable identifier for storing saved searches without
setting a component ID
.
Note that developers may explicitly change
the DataBoundComponent.savedSearchId
at runtime.
In this case, if the saved search ID changes, the component will be associated with a new set of saved searches. When an
explicit savedSearchId
is provided, it will not automatically be changed if a new DataSource is bound to
the component. To keep the saved searches applicable to the current DataSource, developers may want to explicitly
update savedSearchId
in this case.
If you provide your own DataSource for storing searches
, you should enforce the
following restrictions on the server:
userIdField
), and shared or "admin" searches (searches
where the adminField
is true
, or if there
is no admin field, searches where the userIdField
value is null).adminRole
can only add, edit and
remove records where the userIdField
matches their
userId.adminRole
,
also allowing users to add, update and remove admin searches. What this means in concrete terms depends on whether
the dataSource includes an adminField
.userIdField
.userIdField
set to null
. In this case admin users should be able to add, remove and edit
records where the userIdField
matches their own userId, or is null.DataSource for storing searches
, searches
will be stored to each user's browser LocalStorage. Developers should be aware that objects stored in LocalStorage are
accessible by all applications deployed to the same host + port. This means that if you're loading multiple Smart GWT
applications from the save server they could potentially access each others' SavedSearches from localStorage, if the
same userName and componentId exist in both applications.applicationId
value to the
window.location.pathname
which can't be shared by two applications deployed to the same server, but it
could come up if allowNullApplicationId
was set
to true. searchName
field escaping: by default, any character is allowed in the searchName
field, and searchName
are escaped
when
displayed by built-in UI components. If you provide your own UI for saved searches, you should escape the
searchName
field before displaying. Otherwise, users could render your application partly non-functional
by using special characters or inline script, or a malicious admin could inject code into other user's browsers. If you
prefer to just limit the searchName
field to non-special characters, you can just add a dataSourceField validator
to do this, and the built-in UIs for
saved search will handle the validation error as expected (block the save or edit and tell the user what's wrong).
If you fail to implement all of the above, then it will be possible for users to save searches for other users or as admin searches, and those saved searches could have malicious code that is then injected into other user's browsers.
As noted above - the SavedSearches feature requires Smart GWT Pro or better.
factoryCreated, factoryProperties
Constructor and Description |
---|
SavedSearches() |
SavedSearches(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
static SavedSearches |
get()
Singleton accessor method.
|
java.lang.String |
getAdminDefaultField()
Type "boolean".
|
java.lang.String |
getAdminField()
(optional), type "boolean".
|
java.lang.String |
getAdminRole()
The name of the adminRole (used via
Authentication.hasRole() ) to
check to see if the current user has admin privileges. |
boolean |
getAllowNullApplicationId()
If
applicationId is not explicitly specified, it will be
defaulted to the current window.location.pathname. |
java.lang.String |
getApplicationId()
The applicationId that will be saved to
"applicationIdField" to disambiguate from other applications that use the same dataSource. |
java.lang.String |
getApplicationIdField()
Type: "string" (optional).
|
java.lang.String |
getComponentIdField()
Type: "string".
|
java.lang.String |
getDataField()
Type: "string".
|
DataSource |
getDefaultDataSource()
Default DataSource used for persistence of saved searches.
|
java.lang.String |
getDefaultDataSourceAsString()
Default DataSource used for persistence of saved searches.
|
java.lang.String |
getDefaultField()
optional, type "boolean".
|
DataSource |
getLocalDataSource(Canvas componentId)
This method returns an automatically generated custom DataSource to store saved searches for a component in HTML5
localStorage.
|
DataSource |
getLocalDataSource(java.lang.String componentId)
This method returns an automatically generated custom DataSource to store saved searches for a component in HTML5
localStorage.
|
java.lang.String |
getOfflineStorageKey()
If no explicit
defaultDataSource was provided, a
custom HTML5 local storage backed dataSource will be automatically created per component to store saved
searches (see getLocalDataSource() ). |
static SavedSearches |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.lang.String |
getPrimaryKeyField()
Type: "string".
|
java.lang.String |
getProjectIdField()
Type: "string".
|
boolean |
getSaveDefaultSearchToServer()
Should a user's default search preferences be stored to the server?
|
DataSource |
getSavedSearchDataSource(DataBoundComponent component)
Retrieves the DataSource used for persistence of saved searches for some component.
|
java.lang.String |
getSavedSearchId(Canvas component)
Returns the identifier used to uniquely identify saved searches for some component.
|
java.lang.String |
getSavedSearchIDPrefix()
Prefix applied to a specified
DataBoundComponent.savedSearchId by getSavedSearchId() . |
java.lang.String |
getScreenIdField()
Type: "string".
|
java.lang.String |
getSearchNameField()
Type: "string".
|
java.lang.String |
getSetDefaultAdminSearchOperation()
operationId for the custom update operation to invoke
when updating the default admin search. |
java.lang.String |
getSetDefaultUserSearchOperation()
operationId for the custom update operation to invoke
when updating the default user search if saveDefaultSearchToServer is true. |
java.lang.String |
getUserIdField()
Type: "string" (optional).
|
SavedSearches |
setAllowNullApplicationId(boolean allowNullApplicationId)
If
applicationId is not explicitly specified, it will be
defaulted to the current window.location.pathname. |
void |
setDefaultAdminSearch(DataBoundComponent component,
boolean isDefault,
Record searchRecord,
java.lang.String callback)
Update the admin default search for some component
|
void |
setDefaultUserSearch(DataBoundComponent component,
boolean isDefault,
Record searchRecord,
java.lang.String callback)
Update the user's default search.
|
SavedSearches |
setOfflineStorageKey(java.lang.String offlineStorageKey)
If no explicit
defaultDataSource was provided, a
custom HTML5 local storage backed dataSource will be automatically created per component to store saved
searches (see getLocalDataSource() ). |
SavedSearches |
setSaveDefaultSearchToServer(boolean saveDefaultSearchToServer)
Should a user's default search preferences be stored to the server?
|
SavedSearches |
setSavedSearchIDPrefix(java.lang.String savedSearchIDPrefix)
Prefix applied to a specified
DataBoundComponent.savedSearchId by getSavedSearchId() . |
SavedSearches |
setSetDefaultAdminSearchOperation(java.lang.String setDefaultAdminSearchOperation)
operationId for the custom update operation to invoke
when updating the default admin search. |
SavedSearches |
setSetDefaultUserSearchOperation(java.lang.String setDefaultUserSearchOperation)
operationId for the custom update operation to invoke
when updating the default user search if saveDefaultSearchToServer is true. |
applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated
public SavedSearches()
public SavedSearches(com.google.gwt.core.client.JavaScriptObject jsObj)
public static SavedSearches getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public java.lang.String getAdminDefaultField()
The user's chosen
default search is normally stored separately; the adminDefaultField
exists as a way to mark a search as the
default for a user that hasn't chosen one yet.
See the "Default Searches" section of the SavedSearches overview
for more information.
public java.lang.String getAdminField()
public java.lang.String getAdminRole()
Authentication.hasRole()
) to
check to see if the current user has admin privileges.public SavedSearches setAllowNullApplicationId(boolean allowNullApplicationId)
applicationId
is not explicitly specified, it will be
defaulted to the current window.location.pathname. Set this flag to true to disable this behavior and allow SavedSearches to be stored with no explicit applicationId.
Note : This is an advanced setting
allowNullApplicationId
- New allowNullApplicationId value. Default value is falseSavedSearches
instance, for chaining setter callspublic boolean getAllowNullApplicationId()
applicationId
is not explicitly specified, it will be
defaulted to the current window.location.pathname. Set this flag to true to disable this behavior and allow SavedSearches to be stored with no explicit applicationId.
public java.lang.String getApplicationId()
"applicationIdField"
to disambiguate from other applications that use the same dataSource. If no applicationId was
specified, getApplicationId()
will return the current
window.location.pathname by default.
This behavior can be turned off by setting allowNullApplicationId:true
.
The applicationId
allows the same dataSource to be used to store
savedSearches for different applications. It also ensures that if no explicit dataSource
was specified, and searches are being
stored to browser local storage
, saved searches will
be associated with the current application even if another application running under the same domain/port has a
component with the same componentId
.
Returns this.applicationId
if specified, otherwise the current window.location.pathname will be returned by default.
Set allowNullApplicationId
to suppress this behavior of
defaulting to the location.pathname. Default value is null
public java.lang.String getApplicationIdField()
componentId
. Set applicationId
to cause all search lookups to use applicationId
as criteria, and all newly saved searches
to store that applicationId
. Note that if applicationId
is not explicitly set, the window.location.pathname will be used
as a default. This behavior can be disabled by setting allowNullApplicationId
to true.
public java.lang.String getComponentIdField()
Canvas.ID
and is usually a AutoTestLocator
public java.lang.String getDataField()
public DataSource getDefaultDataSource()
component.savedSearchDS
. If no default dataSource is
explicitly provided, the system will automatically generated a custom DataSource for each component that stores saved
searches in HTML5 localStorage
. See getLocalDataSource()
.
This means the searches are only retained for that specific user on that particular machine, and searches cannot be shared with other users. However, this approach does mean that you don't have to provide storage for saved searches and saving searches has no impact on scalability.
If a defaultDataSource
was explicitly specified, it will be
returned, otherwise this method returns null.
To retrieve the dataSource used to store savedSearches for a specific
component see getSavedSearchDataSource()
. Default value is null
public java.lang.String getDefaultDataSourceAsString()
component.savedSearchDS
. If no default dataSource is
explicitly provided, the system will automatically generated a custom DataSource for each component that stores saved
searches in HTML5 localStorage
. See getLocalDataSource()
.
This means the searches are only retained for that specific user on that particular machine, and searches cannot be shared with other users. However, this approach does mean that you don't have to provide storage for saved searches and saving searches has no impact on scalability.
If a defaultDataSource
was explicitly specified, it will be
returned, otherwise this method returns null.
To retrieve the dataSource used to store savedSearches for a specific
component see getSavedSearchDataSource()
. Default value is null
public java.lang.String getDefaultField()
This field is only
required if saveDefaultSearchToServer
is
true.
See the "Default Searches" section of the SavedSearches
overview
for more information.
public SavedSearches setOfflineStorageKey(java.lang.String offlineStorageKey)
defaultDataSource
was provided, a
custom HTML5 local storage
backed dataSource will be automatically created per component to store saved
searches (see getLocalDataSource()
). This property
denotes a base storage key for these dataSources.
The calculated savedSearch identifier
for the component will be appended to this value to create the key to use when
storing serialized searches in local storage.
offlineStorageKey
- New offlineStorageKey value. Default value is "isc_savedSearch_"SavedSearches
instance, for chaining setter callspublic java.lang.String getOfflineStorageKey()
defaultDataSource
was provided, a
custom HTML5 local storage
backed dataSource will be automatically created per component to store saved
searches (see getLocalDataSource()
). This property
denotes a base storage key for these dataSources.
The calculated savedSearch identifier
for the component will be appended to this value to create the key to use when
storing serialized searches in local storage.
public java.lang.String getPrimaryKeyField()
This is expected to be populated automatically when
new search records are added to the data set, so will typically be of type:sequence
.
public java.lang.String getProjectIdField()
screens
, especially Reify Screens
.public SavedSearches setSaveDefaultSearchToServer(boolean saveDefaultSearchToServer)
Default user searches are normally saved in
browser localStorage
- see the "Default Searches" section of the SavedSearches
doc and also the docs for ListGrid.saveDefaultSearch
.
If you want to store the
default search on the server instead, you can add an OperationBinding
of type "update"
called "setDefaultUserSearch"
to your
defaultDataSource
. This will be called with the PK
value of the record to be made the default search, plus a boolean true value for the defaultField
. The expectation is that the search identified by
the PK is marked as default and any other searches previously marked as default are unmarked.
Since Admin Search
records are shared among all users, the expectation is that the underlying storage actually stores default markers
separately from admin searches, and the defaultDataSource
is acting as a facade DataSource
.
Updating a user's default search in the dataSource data should not modify any admin-default search.
saveDefaultSearchToServer
- New saveDefaultSearchToServer value. Default value is falseSavedSearches
instance, for chaining setter callspublic boolean getSaveDefaultSearchToServer()
Default user searches are normally saved in
browser localStorage
- see the "Default Searches" section of the SavedSearches
doc and also the docs for ListGrid.saveDefaultSearch
.
If you want to store the
default search on the server instead, you can add an OperationBinding
of type "update"
called "setDefaultUserSearch"
to your
defaultDataSource
. This will be called with the PK
value of the record to be made the default search, plus a boolean true value for the defaultField
. The expectation is that the search identified by
the PK is marked as default and any other searches previously marked as default are unmarked.
Since Admin Search
records are shared among all users, the expectation is that the underlying storage actually stores default markers
separately from admin searches, and the defaultDataSource
is acting as a facade DataSource
.
Updating a user's default search in the dataSource data should not modify any admin-default search.
public SavedSearches setSavedSearchIDPrefix(java.lang.String savedSearchIDPrefix)
DataBoundComponent.savedSearchId
by getSavedSearchId()
.
This is required to handle the case where a component's savedSearchId matches the ID of some other component.
Note : This is an advanced setting
savedSearchIDPrefix
- New savedSearchIDPrefix value. Default value is "SSID:"SavedSearches
instance, for chaining setter callspublic java.lang.String getSavedSearchIDPrefix()
DataBoundComponent.savedSearchId
by getSavedSearchId()
.
This is required to handle the case where a component's savedSearchId matches the ID of some other component.public java.lang.String getScreenIdField()
screens
, especially Reify Screens
.public java.lang.String getSearchNameField()
public SavedSearches setSetDefaultAdminSearchOperation(java.lang.String setDefaultAdminSearchOperation)
operationId
for the custom update operation to invoke
when updating the default admin search. The update data for this operation will be the saved search record to mark
as the shared default with the adminDefaultField
set
to indicate whether the saved search is being set or cleared.
When marking a search as the new shared default, the
dataSource implementation for this custom update operation must clear the adminDefaultField value on any previous
shared default search. The server should also use the dsResponse.relatedUpdates
feature to notify the
client that the previous default was unset.
setDefaultAdminSearchOperation
- New setDefaultAdminSearchOperation value. Default value is "setDefaultAdminSearch"SavedSearches
instance, for chaining setter callspublic java.lang.String getSetDefaultAdminSearchOperation()
operationId
for the custom update operation to invoke
when updating the default admin search. The update data for this operation will be the saved search record to mark
as the shared default with the adminDefaultField
set
to indicate whether the saved search is being set or cleared.
When marking a search as the new shared default, the
dataSource implementation for this custom update operation must clear the adminDefaultField value on any previous
shared default search. The server should also use the dsResponse.relatedUpdates
feature to notify the
client that the previous default was unset.
public SavedSearches setSetDefaultUserSearchOperation(java.lang.String setDefaultUserSearchOperation)
operationId
for the custom update operation to invoke
when updating the default user search if saveDefaultSearchToServer
is true. The update data for this operation will be the saved search record to mark as
the user default with the defaultField
set to indicate
whether the saved search is being set or cleared.
Note : This is an advanced setting
setDefaultUserSearchOperation
- New setDefaultUserSearchOperation value. Default value is "setDefaultUserSearch"SavedSearches
instance, for chaining setter callspublic java.lang.String getSetDefaultUserSearchOperation()
operationId
for the custom update operation to invoke
when updating the default user search if saveDefaultSearchToServer
is true. The update data for this operation will be the saved search record to mark as
the user default with the defaultField
set to indicate
whether the saved search is being set or cleared.
public java.lang.String getUserIdField()
userId
of the user saving the search, populated from
the current userId
. This field is only optional in the
sense that you could instead build a DataSource that returns user-specific saved searches through some other mechanism
(for example, by inserting a userId value and forcing userId criteria on the server side).public DataSource getLocalDataSource(Canvas componentId)
shared default dataSource
specified, and if ListGrid.savedSearchDS
is not set for the component. The
offline storage key for the data will be generated by combining the offlineStorageKey
with the component identifier retrieved
from getSavedSearchId()
.
Note: The
dataSources returned by this method will suppress logging their requests to the Developer Console RPC tag
by default. This is done so developers can more
easily see dataSource requests and responses that were explicitly initiated by application code, to simplify debugging.
However, if a developer has explicitly created a SavedSearch dataSource either as the global default
or at the component level
, requests to access and update SavedSearch
data will be logged as with any other dataSource.
componentId
- Component to retrieve the dataSource for, or saved search component identifier as returned by getSavedSearchId()
public DataSource getLocalDataSource(java.lang.String componentId)
shared default dataSource
specified, and if ListGrid.savedSearchDS
is not set for the component. The
offline storage key for the data will be generated by combining the offlineStorageKey
with the component identifier retrieved
from getSavedSearchId()
.
Note: The
dataSources returned by this method will suppress logging their requests to the Developer Console RPC tag
by default. This is done so developers can more
easily see dataSource requests and responses that were explicitly initiated by application code, to simplify debugging.
However, if a developer has explicitly created a SavedSearch dataSource either as the global default
or at the component level
, requests to access and update SavedSearch
data will be logged as with any other dataSource.
componentId
- Component to retrieve the dataSource for, or saved search component identifier as returned by getSavedSearchId()
public DataSource getSavedSearchDataSource(DataBoundComponent component)
If component.savedSearchDS
is specified this will be
returned.
Otherwise if an explicit default
dataSource
was specified, it will be used.
If no explicit dataSource was provided either at the component level
or as a default for all SavedSearches, this method will return the result of getLocalDataSource()
.
component
- component to retrieve the SavedSearch dataSource forpublic java.lang.String getSavedSearchId(Canvas component)
This is the value that will be
set on the componentIdField
when storing saved
searches to a DataSource.
If there is no explicly specified dataSource for storing saved searches, it will also be
used to configure the offline storage key for data stored by the automatically generated local storage backed dataSource
for the component.
The returned value is calculated as follows:
DataBoundComponent.savedSearchId
is set, this method
will return the savedSearchIDPrefix
+
component.savedSearchId
.local ID
(which falls back to the global ID
if no local ID is present) will be returned. If DataBoundComponent.showSavedSearchesByDS
is set
and the component has a DataSource, the method will instead return the local ID + ":" + the DataSource ID,
where the delimiter avoids potential collisions otherwise possible. If no explicit component savedSearchId
was set,
the system will rely on the widget's local or global ID, which can change unless explicit due to app changes, and on
the DataSource ID bound to the component, which may change at runtime. Since this property is used to identify the
savedSearch records associated with this component, when it changes a different set of saved searches will be available
to the user.
If you want to control this explicitly, you can do so by setting an explicit savedSearchId
. Changing the savedSearchId
at runtime also allows you to deliberately associate a component with a new set of SavedSearches depending on
application state. One common case where this might be desirable is if a component is bound to a dataSource and you want
to bind to a new DataSource where the savedSearch criteria would not be applicable.
component
- component to retrieve the identifier forpublic void setDefaultAdminSearch(DataBoundComponent component, boolean isDefault, Record searchRecord, java.lang.String callback)
This will invoke the setDefaultAdminSearchOperation
to update the
admin search record on the server.
component
- component being updatedisDefault
- whether the default is being set to true or falsesearchRecord
- record containing details of the search to be updatedcallback
- callback to invoke when the search has been updated. Takes no arguments.
See Callback
public void setDefaultUserSearch(DataBoundComponent component, boolean isDefault, Record searchRecord, java.lang.String callback)
This will invoke the setDefaultUserSearchOperation
if saveDefaultSearchToServer
is true, otherwise it
will persist the default into offline storage
component
- component being updatedisDefault
- whether the default is being set to true or falsesearchRecord
- record containing details of the search to be updatedcallback
- callback to invoke when the search has been updated. Takes no arguments.
See Callback
public static SavedSearches get()