Class LocalizedImageResource
- All Implemented Interfaces:
Serializable
,IClusterable
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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
bind()
Binds this resource if it is sharedfinal IResource
return the resourcefinal ResourceReference
return the resourcefinal boolean
final void
onResourceRequested
(PageParameters parameters) final void
setResource
(IResource resource) final void
setResourceReference
(ResourceReference resourceReference) final void
setResourceReference
(ResourceReference resourceReference, PageParameters resourceParameters) final void
-
Constructor Details
-
LocalizedImageResource
Constructor- Parameters:
component
- The component that owns this localized image resource
-
-
Method Details
-
bind
Binds this resource if it is shared -
onResourceRequested
- Parameters:
parameters
- page parameters
-
setResource
- Parameters:
resource
- The resource to set.
-
setResourceReference
- Parameters:
resourceReference
- The resource to set.
-
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
- 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
return the resource- Returns:
- resource or
null
if there is none
-
getResourceReference
return the resource- Returns:
- resource or
null
if there is none
-