|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectwicket.ResourceReference
ResourceReference is essentially a reference to an actual resource which is shared through the Application. A ResourceReference has a name and a scope (within which the name must be unique). It may also have a locale or style. The locale and/or style do not need to be set on a resource reference because those values will automatically be determined based on the context in which the resource is being used. For example, if a ResourceReference is attached to an Image component, when the locale for the page switches, the Image component will notice this and automatically change the locale for the referenced resource as appropriate. It's for this reason that there are no constructor overloads taking a Locale or style (these details are essentially internal and so the framework uses setLocale/setStyle internally so you don't have to worry about it).
Resources may be added to the Application when the Application is constructed
using
Application.getSharedResources() followed by
SharedResources.add(Class, String, Locale, String, Resource),
SharedResources.add(String, Locale, Resource)or
SharedResources.add(String, Resource).
If a component has its own shared resource which should not be added to the
application construction logic in this way, it can lazy-initialize the
resource by overriding the newResource()method. In
this method, the component should supply logic that creates the shared
resource.
| Constructor Summary | |
ResourceReference(java.lang.Class scope,
java.lang.String name)
Constructs a ResourceReference with the given scope and name. |
|
ResourceReference(java.lang.String name)
Contructs a resource reference with Application.class scope and the given name. |
|
| Method Summary | |
void |
bind(Application application)
Binds this shared resource to the given application. |
java.util.Locale |
getLocale()
|
java.lang.String |
getName()
|
java.lang.String |
getPath()
|
Resource |
getResource()
Gets the resource for this resource reference. |
java.lang.Class |
getScope()
|
java.lang.String |
getStyle()
|
void |
invalidate()
Sets any loaded resource to null, thus forcing a reload on the next request. |
protected Resource |
newResource()
Factory method for lazy initialization of shared resources. |
void |
setLocale(java.util.Locale locale)
|
void |
setStyle(java.lang.String style)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ResourceReference(java.lang.Class scope,
java.lang.String name)
scope - The scope of the namename - The name of the resourcepublic ResourceReference(java.lang.String name)
name - The name of the resource| Method Detail |
public final void bind(Application application)
application - The application which holds the shared resourcepublic final java.util.Locale getLocale()
public final java.lang.String getName()
public final java.lang.String getPath()
public final Resource getResource()
bind(Application)this method may return null.
public final java.lang.Class getScope()
public final java.lang.String getStyle()
Session)public final void invalidate()
public final void setLocale(java.util.Locale locale)
locale - The locale to set.public final void setStyle(java.lang.String style)
style - The style to set (see Session).public java.lang.String toString()
Object.toString()protected Resource newResource()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||