Class LocalizedImageResource
- java.lang.Object
-
- org.apache.wicket.markup.html.image.resource.LocalizedImageResource
-
- All Implemented Interfaces:
Serializable
,IClusterable
public final class LocalizedImageResource extends Object implements IClusterable
THIS CLASS IS INTENDED FOR INTERNAL USE IN IMPLEMENTING LOCALE SENSITIVE COMPONENTS THAT USE IMAGE RESOURCES AND SHOULD NOT BE USED DIRECTLY BY END-USERS.This class contains the logic for extracting static image resources referenced by the SRC attribute of component tags and keeping these static image resources in sync with the component locale.
If no image is specified by the SRC attribute of an IMG tag, then any VALUE attribute is inspected. If there is a VALUE attribute, it must be of the form "[factoryName]:[sharedImageName]?:[specification]". [factoryName] is the name of a resource factory that has been added to Application (for example, DefaultButtonImageResourceFactory is installed by default under the name "buttonFactory"). The [sharedImageName] value is optional and gives a name under which a given generated image is shared. For example, a cancel button image generated by the VALUE attribute "buttonFactory:cancelButton:Cancel" is shared under the name "cancelButton" and this specification will cause a component to reference the same image resource no matter what page it appears on, which is a very convenient and efficient way to create and share images. The [specification] string which follows the second colon is passed directly to the image factory and its format is dependent on the specific image factory. For details on the default buttonFactory, see
DefaultButtonImageResourceFactory
.Finally, if there is no SRC attribute and no VALUE attribute, the Image component's model is inspected. If the model contains a resource or resource reference, this image is used, otherwise the model is converted to a String and that value is used as a path to load the image.
- Author:
- Jonathan Locke
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalizedImageResource(Component component)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind()
Binds this resource if it is sharedIResource
getResource()
return the resourceResourceReference
getResourceReference()
return the resourceboolean
isStateless()
void
onResourceRequested(PageParameters parameters)
void
setResource(IResource resource)
void
setResourceReference(ResourceReference resourceReference)
void
setResourceReference(ResourceReference resourceReference, PageParameters resourceParameters)
void
setSrcAttribute(ComponentTag tag)
-
-
-
Constructor Detail
-
LocalizedImageResource
public LocalizedImageResource(Component component)
Constructor- Parameters:
component
- The component that owns this localized image resource
-
-
Method Detail
-
bind
public final void bind()
Binds this resource if it is shared
-
onResourceRequested
public final void onResourceRequested(PageParameters parameters)
- Parameters:
parameters
- page parameters
-
setResource
public final void setResource(IResource resource)
- Parameters:
resource
- The resource to set.
-
setResourceReference
public final void setResourceReference(ResourceReference resourceReference)
- Parameters:
resourceReference
- The resource to set.
-
isStateless
public final boolean isStateless()
- Returns:
- true if it has a resourceReference. (it points to a shared resource)
-
setResourceReference
public final void setResourceReference(ResourceReference resourceReference, PageParameters resourceParameters)
- Parameters:
resourceReference
- The resource to set.resourceParameters
- The resource parameters for the shared resource
-
setSrcAttribute
public final void setSrcAttribute(ComponentTag tag)
- Parameters:
tag
- The tag to inspect for an optional src attribute that might reference an image.- Throws:
WicketRuntimeException
- Thrown if an image is required by the caller, but none can be found.
-
getResource
public final IResource getResource()
return the resource- Returns:
- resource or
null
if there is none
-
getResourceReference
public final ResourceReference getResourceReference()
return the resource- Returns:
- resource or
null
if there is none
-
-