!--a11y-->
ICacheDiscriminator InterfaceThis method provided by this interface returns null by default. A component must override this method to enable multicache behavior.
public String getCacheDiscriminator(IPortalComponentRequest request) |
A discriminator is used as a key to store and to get the cache content.
A component displaying the weather that uses a discriminator to add a cache content for each city that are passed through the request.
package com.sapportals.portal.prt.test.component; import com.sapportals.portal.prt.component.*; import com.sapportals.portal.prt.event.IPortalRequestEvent;
public class WeatherComponent implements ICacheDiscriminator { private final String SELECTED_CITY = "SelectedCity"; private final String CITY_PROPERTY = "City";
public void doContent( IPortalComponentRequest request, IPortalComponentResponse response) { String cityName = (String) request.getNode().getValue(CITY_PROPERTY);
..........................make a content........................... }
/** * stores the selected city in the component profile */ public void doSelect( IPortalComponentRequest aRequest, IPortalRequestEvent event) { String cityName = (String) aRequest.getParameter("SELECTED_CITY"); aRequest.getNode().putValue(CITY_PROPERTY, cityName); }
/** * Gets the caching level. */ public CachingLevel getCachingLevel(IPortalComponentRequest request) { return CachingLevel.USER; }
/** * Gets the cache discriminator. * Here the cache depends on the selected city */ public String getCacheDiscriminator(IPortalComponentRequest request) { String cityName = (String) request.getNode().getValue(CITY_PROPERTY); return cityName; } } |
