Class ContextRelativeResourceReference
- java.lang.Object
-
- org.apache.wicket.request.resource.ResourceReference
-
- org.apache.wicket.request.resource.ContextRelativeResourceReference
-
- All Implemented Interfaces:
java.io.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 (seeisMinifyIt()) to decide if referenced resource can be minified (ex: '/css/coolTheme.min.css') or not.- Author:
- Andrea Del Bene
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.ResourceReference
ResourceReference.Key, ResourceReference.LambdaResourceReference, ResourceReference.UrlAttributes
-
-
Constructor Summary
Constructors Constructor Description ContextRelativeResourceReference(java.lang.String name)Instantiates a new context relative resource reference for the given name.ContextRelativeResourceReference(java.lang.String name, boolean minifyIt)Instantiates a new context relative resource reference for the given name.ContextRelativeResourceReference(java.lang.String name, java.lang.String minPostfix)Instantiates a new context relative resource reference for the given name.ContextRelativeResourceReference(java.lang.String name, java.lang.String minPostfix, boolean minifyIt)Instantiates a new context relative resource reference for the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ContextRelativeResourcebuildContextRelativeResource(java.lang.String name, java.lang.String minPostfix)Build the context-relative resource for this resource reference.protected booleancanBeMinified()Says if the referenced resource can be minified.java.lang.StringgetMinPostfix()Gets the minified postfix we use for this resource.ContextRelativeResourcegetResource()Returns the resource.booleanisMinifyIt()Returns the flag that says if the resource can be minified (true) or not (false).-
Methods inherited from class org.apache.wicket.request.resource.ResourceReference
canBeRegistered, equals, getDependencies, getExtension, getKey, getLocale, getName, getScope, getStyle, getUrlAttributes, getVariation, hashCode, of, of, toString
-
-
-
-
Constructor Detail
-
ContextRelativeResourceReference
public ContextRelativeResourceReference(java.lang.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(java.lang.String name, boolean minifyIt)Instantiates a new context relative resource reference for the given name. ParameterminifyItsays if the resource can be minified (true) or not (false).- Parameters:
name- the resource nameminifyIt- says if the resource name can be minified or not
-
ContextRelativeResourceReference
public ContextRelativeResourceReference(java.lang.String name, java.lang.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 nameminPostfix- the minfied postfix
-
ContextRelativeResourceReference
public ContextRelativeResourceReference(java.lang.String name, java.lang.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 parameterminifyItsays if the resource can be minified (true) or not (false).- Parameters:
name- the resource nameminPostfix- the minfied postfixminifyIt- says if the resource name can be minified or not
-
-
Method Detail
-
buildContextRelativeResource
protected ContextRelativeResource buildContextRelativeResource(java.lang.String name, java.lang.String minPostfix)
Build the context-relative resource for this resource reference.- Parameters:
name- the resource nameminPostfix- 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 returnstrueif both flagminifyItand application's resource settings methodResourceSettings.getUseMinifiedResources()} are true.- Returns:
trueif resource can be minified,falseotherwise
-
getResource
public final ContextRelativeResource getResource()
Description copied from class:ResourceReferenceReturns the resource.- Specified by:
getResourcein classResourceReference- Returns:
- resource instance
-
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 java.lang.String getMinPostfix()
Gets the minified postfix we use for this resource.- Returns:
- the minified postfix
-
-