java.lang.Object
org.apache.wicket.SharedResources
Class which holds shared resources. Resources can be shared by name. An optional scope can be
given to prevent naming conflicts and a locale and/or style can be given as well.
Unlike component hosted resources, shared resources have stable URLs, which makes them suitable
for indexing by web crawlers and caching by web browsers. As they are also not synchronised on
the Session
, they can be loaded asynchronously, which is important with images and
resources such as JavaScript and CSS.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds a resource.final void
Adds a resource.final void
Adds a resource.Resolves aResourceReference
for a shared resource.final ResourceReference
Resolves aResourceReference
for a shared resource by usingApplication
as a scope andnull
for locale, style and variation.final ResourceReference
Removes a resource.
-
Constructor Details
-
SharedResources
Construct.- Parameters:
registry
-
-
-
Method Details
-
add
public final void add(Class<?> scope, String name, Locale locale, String style, String variation, IResource resource) Adds a resource.- Parameters:
scope
- Scope of resourcename
- Logical name of resourcelocale
- The locale of the resourcestyle
- The resource style (seeSession
)variation
- The component specific variation of the styleresource
- Resource to store
-
add
Adds a resource.- Parameters:
name
- Logical name of resourcelocale
- The locale of the resourceresource
- Resource to store
-
add
Adds a resource.- Parameters:
name
- Logical name of resourceresource
- Resource to store
-
get
Resolves aResourceReference
for a shared resource by usingApplication
as a scope andnull
for locale, style and variation.- Parameters:
name
- Logical name of resource
-
get
public ResourceReference get(Class<?> scope, String name, Locale locale, String style, String variation, boolean strict) Resolves aResourceReference
for a shared resource.- Parameters:
scope
- Scope of resourcename
- Logical name of resourcelocale
- The locale of the resourcestyle
- The resource style (seeSession
)variation
- The component specific variation of the stylestrict
- If true, "weaker" combination of scope, name, locale etc. are not tested- Returns:
- Either the resource reference found in the registry or, if requested, a resource reference automatically created based on the parameters provided. The automatically created resource reference will automatically be added to the registry.
-
remove
Removes a resource.- Parameters:
key
- the resource reference's identifier- Returns:
- the removed
ResourceReference
.null
if there was no registration for thisResourceReference.Key
-