Class BaseDataResource<T>
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.BaseDataResource<T>
-
- Type Parameters:
T- The type of the data this resource can deliver
- All Implemented Interfaces:
java.io.Serializable,IResource,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
ByteArrayResource,CharSequenceResource
public abstract class BaseDataResource<T> extends AbstractResource
An abstract resource that can deliver static data - passed to the constructor, or dynamic - returned bygetData(org.apache.wicket.request.resource.IResource.Attributes)- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ContentRangeType, AbstractResource.ResourceResponse, AbstractResource.WriteCallback
-
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description BaseDataResource(java.lang.String contentType)Creates aBaseDataResourcewhich will provide its data dynamically withgetData(org.apache.wicket.request.resource.IResource.Attributes)BaseDataResource(java.lang.String contentType, T data)Creates a Resource from the given data with its content typeBaseDataResource(java.lang.String contentType, T data, java.lang.String filename)Creates a Resource from the given data with its content type and filename
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidconfigureResponse(AbstractResource.ResourceResponse response, IResource.Attributes attributes)Post-configures the given response, e.g.protected TgetData(IResource.Attributes attributes)Gets the data for this resource.protected java.lang.StringgetFilename()Returns the filename that will be set as the Content-Disposition header.protected abstract java.lang.LonggetLength(T data)protected AbstractResource.ResourceResponsenewResourceResponse(IResource.Attributes attributes)Override this method to return aAbstractResource.ResourceResponsefor the request.protected abstract voidwriteData(org.apache.wicket.request.Response response, T data)Writes the given data to the response-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
BaseDataResource
public BaseDataResource(java.lang.String contentType)
Creates aBaseDataResourcewhich will provide its data dynamically withgetData(org.apache.wicket.request.resource.IResource.Attributes)- Parameters:
contentType- The Content type of the array.
-
BaseDataResource
public BaseDataResource(java.lang.String contentType, T data)Creates a Resource from the given data with its content type- Parameters:
contentType- The Content type of the array.data- The data
-
BaseDataResource
public BaseDataResource(java.lang.String contentType, T data, java.lang.String filename)Creates a Resource from the given data with its content type and filename- Parameters:
contentType- The Content type of the array.data- The datafilename- The filename that will be set as the Content-Disposition header.
-
-
Method Detail
-
configureResponse
protected void configureResponse(AbstractResource.ResourceResponse response, IResource.Attributes attributes)
Post-configures the given response, e.g. set/override response headers.- Parameters:
response- The response to configureattributes- The request attributes (web request, web response, parameters)
-
newResourceResponse
protected AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Description copied from class:AbstractResourceOverride this method to return aAbstractResource.ResourceResponsefor the request.- Specified by:
newResourceResponsein classAbstractResource- Parameters:
attributes- request attributes- Returns:
- resource data instance
-
writeData
protected abstract void writeData(org.apache.wicket.request.Response response, T data)Writes the given data to the response- Parameters:
response- The response to write todata- The data to write
-
getLength
protected abstract java.lang.Long getLength(T data)
- Parameters:
data- The data to be written- Returns:
- The length of the data to be written. Used to set "Content-Length" response header
-
getData
protected T getData(IResource.Attributes attributes)
Gets the data for this resource.- Parameters:
attributes- the context bringing the request, response and the parameters- Returns:
- The data for this resource
-
getFilename
protected java.lang.String getFilename()
Returns the filename that will be set as the Content-Disposition header.- Returns:
- the filename
-
-