Class ContextRelativeResourceReference

  • All Implemented Interfaces:
    Serializable, org.apache.wicket.util.io.IClusterable

    public class ContextRelativeResourceReference
    extends ResourceReference
    This is a ResourceReference to handle context-relative resources such as js, css and picture files placed in a folder on the context root (ex: '/css/coolTheme.css'). The class has a flag (see isMinifyIt()) to decide if referenced resource can be minified (ex: '/css/coolTheme.min.css') or not.
    Author:
    Andrea Del Bene
    See Also:
    Serialized Form
    • Constructor Detail

      • ContextRelativeResourceReference

        public ContextRelativeResourceReference​(String name)
        Instantiates a new context relative resource reference for the given name. The resource will be minified in DEPLOYMENT mode and "min" will be used as postfix.
        Parameters:
        name - the resource name
      • ContextRelativeResourceReference

        public ContextRelativeResourceReference​(String name,
                                                boolean minifyIt)
        Instantiates a new context relative resource reference for the given name. Parameter minifyIt says if the resource can be minified (true) or not (false).
        Parameters:
        name - the resource name
        minifyIt - says if the resource name can be minified or not
      • ContextRelativeResourceReference

        public ContextRelativeResourceReference​(String name,
                                                String minPostfix)
        Instantiates a new context relative resource reference for the given name. We can specify which postfix we want to use for minification with parameter @code minPostfix}
        Parameters:
        name - the resource name
        minPostfix - the minfied postfix
      • ContextRelativeResourceReference

        public ContextRelativeResourceReference​(String name,
                                                String minPostfix,
                                                boolean minifyIt)
        Instantiates a new context relative resource reference for the given name. We can specify which postfix we want to use for minification with parameter @code minPostfix} while parameter minifyIt says if the resource can be minified (true) or not (false).
        Parameters:
        name - the resource name
        minPostfix - the minfied postfix
        minifyIt - says if the resource name can be minified or not
    • Method Detail

      • buildContextRelativeResource

        protected ContextRelativeResource buildContextRelativeResource​(String name,
                                                                       String minPostfix)
        Build the context-relative resource for this resource reference.
        Parameters:
        name - the resource name
        minPostfix - the postfix to use to minify the resource name (typically "min")
        Returns:
        the context-relative resource
      • canBeMinified

        protected boolean canBeMinified()
        Says if the referenced resource can be minified. It returns true if both flag minifyIt and application's resource settings method ResourceSettings.getUseMinifiedResources()} are true.
        Returns:
        true if resource can be minified, false otherwise
      • isMinifyIt

        public boolean isMinifyIt()
        Returns the flag that says if the resource can be minified (true) or not (false).
        Returns:
        true, if resource can be minified
      • getMinPostfix

        public String getMinPostfix()
        Gets the minified postfix we use for this resource.
        Returns:
        the minified postfix