CachingFilter
The CachingFilter
is similar to the ELMappingFilter
but instead of storing the data attributes or control values in the repository of the entity it creates a new ObjectMap and stores it under a given name in the specified repository. Thus, it is similar to the CollectingFilter
with the difference of storing complete ObjectMaps instead of single values.
Configuration
Name | Type, usage constraints, defaults | Description |
---|---|---|
repository | required: paraVal default: none type: string | The repository name used to store the cache objects. |
cacheName | required: paraVal default: none type: string | The name under which the ObjectMap is stored in the repository. |
Example
The following example shows how the CachingFilter
can be used to store user data in a cache:
<dataFilter type="CachingFilter">
<!-- the filter configuration -->
<dp:paraVal name="repository" value="storage" />
<dp:paraVal name="cacheName" value="#{in.user.id}" />
<!-- attribute created on the control object -->
<dp:ctlVal name="id" value="#{in.user.id}"/>
<dp:ctlVal name="name" value="#{in.user.name}"/>
</dataFilter>
A filter of a subsequent entity “user” uses the cached users for filtering:
<dataFilter type="ELMappingFilter">
<dp:paraVal name="skipwhen" value="#{ctx:hasKey(ctl.storage, in.user.uid)}" />
</dataFilter>
A filter of a subsequent entity “data” uses the cached users for data enrichment:
<dataFilter type="ELMappingFilter">
<dp:attrVal name="name" value="#{in.storage[in.data.userId],name"/>
</dataFilter>
An entity uses the cached data as DataSource:
<dataSource type="BeanDataSource">
<dp:paraVal name="bean" value="#{ctl.storage}"/>
</dataSource>