org.apache.wicket
Class Resource

java.lang.Object
  extended by org.apache.wicket.Resource
All Implemented Interfaces:
java.io.Serializable, IClusterable, IRequestListener, IResourceListener
Direct Known Subclasses:
WebResource

public abstract class Resource
extends java.lang.Object
implements IResourceListener

A Resource is something that implements IResourceListener and provides a getResourceStream() method which returns the raw IResourceStream to be rendered back to the client browser.

Resources themselves do not currently have URLs. Instead, they are referred to by components that have URLs.

Resources can be shared throughout an application by adding them to Application with addResource(Class scope, String name) or addResource(String name). A resource added in such a way is a named resource and is accessible throughout the application via Application.getResource(Class scope, String name) or Application.getResource(String name). The ResourceReference class enables easy access to such resources in a way that is light on clusters.

While resources can be shared between components, it is important to emphasize that components cannot be shared among containers. For example, you can create a button image resource with new DefaultButtonImageResource(...) and store that in the Application with addResource(). You can then assign that logical resource via ResourceReference to several ImageButton components. While the button image resource can be shared between components like this, the ImageButton components in this example are like all other components in Wicket and cannot be shared.

Author:
Jonathan Locke, Johan Compagner, Gili Tzabari, Igor Vaynberg
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.wicket.IResourceListener
INTERFACE
 
Constructor Summary
protected Resource()
          Constructor
 
Method Summary
protected  void configureResponse(Response response)
          Allows implementations to do configure the response, like setting headers etc.
protected  ValueMap getParameters()
           
abstract  IResourceStream getResourceStream()
           
protected  void invalidate()
          Sets any loaded resource to null, thus forcing a reload on the next request.
 boolean isCacheable()
           
 void onResourceRequested()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 Resource setCacheable(boolean cacheable)
          Should this resource be cacheable, so will it set the last modified and the some cache headers in the response.
 void setParameters(java.util.Map parameters)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Resource

protected Resource()
Constructor

Method Detail

getResourceStream

public abstract IResourceStream getResourceStream()
Returns:
Gets the resource to render to the requester

isCacheable

public final boolean isCacheable()
Returns:
boolean True or False if this resource is cacheable

onResourceRequested

public final void onResourceRequested()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. Called when a resource is requested.

Specified by:
onResourceRequested in interface IResourceListener

setCacheable

public final Resource setCacheable(boolean cacheable)
Should this resource be cacheable, so will it set the last modified and the some cache headers in the response.

Parameters:
cacheable - boolean if the lastmodified and cache headers must be set.
Returns:
this

setParameters

public final void setParameters(java.util.Map parameters)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!

Parameters:
parameters - Map of query parameters that parameterize this resource

configureResponse

protected void configureResponse(Response response)
Allows implementations to do configure the response, like setting headers etc.

Parameters:
response - the response

getParameters

protected ValueMap getParameters()
Returns:
Any query parameters associated with the request for this resource

invalidate

protected void invalidate()
Sets any loaded resource to null, thus forcing a reload on the next request.



Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.