Class SharedResources

java.lang.Object
org.apache.wicket.SharedResources

public class SharedResources extends Object
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 Details

  • 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 resource
      name - Logical name of resource
      locale - The locale of the resource
      style - The resource style (see Session)
      variation - The component specific variation of the style
      resource - Resource to store
    • add

      public final void add(String name, Locale locale, IResource resource)
      Adds a resource.
      Parameters:
      name - Logical name of resource
      locale - The locale of the resource
      resource - Resource to store
    • add

      public final void add(String name, IResource resource)
      Adds a resource.
      Parameters:
      name - Logical name of resource
      resource - Resource to store
    • get

      public final ResourceReference get(String name)
      Resolves a ResourceReference for a shared resource by using Application as a scope and null 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 a ResourceReference for a shared resource.
      Parameters:
      scope - Scope of resource
      name - Logical name of resource
      locale - The locale of the resource
      style - The resource style (see Session)
      variation - The component specific variation of the style
      strict - 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 this ResourceReference.Key