org.apache.wicket.request.resource
Class AbstractResource.ResourceResponse

java.lang.Object
  extended by org.apache.wicket.request.resource.AbstractResource.ResourceResponse
Enclosing class:
AbstractResource

public static class AbstractResource.ResourceResponse
extends java.lang.Object

Represents data used to configure response and write resource data.

Author:
Matej Knopp

Constructor Summary
AbstractResource.ResourceResponse()
          Construct.
 
Method Summary
 boolean dataNeedsToBeWritten(IResource.Attributes attributes)
          Check to determine if the resource data needs to be written.
 long getCacheDuration()
           
 ContentDisposition getContentDisposition()
           
 long getContentLength()
           
 java.lang.String getContentType()
           
 java.lang.Integer getErrorCode()
           
 java.lang.String getFileName()
           
 java.util.Date getLastModified()
           
protected  java.lang.String getTextEncoding()
           
 AbstractResource.WriteCallback getWriteCallback()
           
 boolean isCacheable()
           
 void setCacheable(boolean cacheable)
          Cachable resources are cached on client.
 void setCacheDuration(long cacheDuration)
          Sets the duration for which this resource should be cached on client (in seconds).
 void setContentDisposition(ContentDisposition contentDisposition)
          Determines whether the resource will be inline or an attachment.
 void setContentLength(long contentLength)
          Sets the content length (in bytes) of the data.
 void setContentType(java.lang.String contentType)
          Sets the content type for the resource.
 void setErrorCode(java.lang.Integer errorCode)
          Sets the error code for resource.
 void setFileName(java.lang.String fileName)
          Sets the file name of the resource.
 void setLastModified(java.util.Date lastModified)
          Sets the last modified data of the resource.
 void setTextEncoding(java.lang.String textEncoding)
          Sets the text encoding for the resource.
 void setWriteCallback(AbstractResource.WriteCallback writeCallback)
          Sets the AbstractResource.WriteCallback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResource.ResourceResponse

public AbstractResource.ResourceResponse()
Construct.

Method Detail

setErrorCode

public void setErrorCode(java.lang.Integer errorCode)
Sets the error code for resource. If there is an error code set the data will not be rendered and the code will be sent to client.

Parameters:
errorCode -

getErrorCode

public java.lang.Integer getErrorCode()
Returns:
error code or null

setFileName

public void setFileName(java.lang.String fileName)
Sets the file name of the resource.

Parameters:
fileName -

getFileName

public java.lang.String getFileName()
Returns:
resource file name

setContentDisposition

public void setContentDisposition(ContentDisposition contentDisposition)
Determines whether the resource will be inline or an attachment.

Parameters:
contentDisposition -
See Also:
ContentDisposition

getContentDisposition

public ContentDisposition getContentDisposition()
Returns:
whether the resource is inline or attachment

setContentType

public void setContentType(java.lang.String contentType)
Sets the content type for the resource. If no content type is set it will be determined by the extension.

Parameters:
contentType -

getContentType

public java.lang.String getContentType()
Returns:
resource content type

setTextEncoding

public void setTextEncoding(java.lang.String textEncoding)
Sets the text encoding for the resource. The encoding is only used if the content type indicates a textual resource.

Parameters:
textEncoding -

getTextEncoding

protected java.lang.String getTextEncoding()
Returns:
text encoding for resource

setContentLength

public void setContentLength(long contentLength)
Sets the content length (in bytes) of the data. Content length is optional but it's recommended to set it so that the browser can show download progress.

Parameters:
contentLength -

getContentLength

public long getContentLength()
Returns:
content length (in bytes)

setLastModified

public void setLastModified(java.util.Date lastModified)
Sets the last modified data of the resource. Even though this method is optional it is recommended to set the date. If the date is set properly Wicket can check the If-Modified-Since to determine if the actuall data really needs to be sent to client.

Parameters:
lastModified -

getLastModified

public java.util.Date getLastModified()
Returns:
last modified date

dataNeedsToBeWritten

public boolean dataNeedsToBeWritten(IResource.Attributes attributes)
Check to determine if the resource data needs to be written. This method checks the If-Modified-Since request header and compares it to lastModified property. In order for this method to work setLastModified(Date) has to be called first.

Parameters:
attributes -
Returns:
true if the resource data does need to be written, false otherwise.

setCacheable

public void setCacheable(boolean cacheable)
Cachable resources are cached on client. This flag affects the Expires and Cache-Control headers.

Parameters:
cacheable -
See Also:
#setCacheDuration(int)

isCacheable

public boolean isCacheable()
Returns:
returns whether this resource is cacheable

setCacheDuration

public void setCacheDuration(long cacheDuration)
Sets the duration for which this resource should be cached on client (in seconds). #see IResourceSettings.setDefaultCacheDuration(int)

Parameters:
cacheDuration -

getCacheDuration

public long getCacheDuration()
Returns:
duration for which the resource shoudl be cached on client (in seconds)

setWriteCallback

public void setWriteCallback(AbstractResource.WriteCallback writeCallback)
Sets the AbstractResource.WriteCallback. The callback is responsible for generating the response data.

It is necessary to set the AbstractResource.WriteCallback if #dataNeedsToBeWritten(org.apache.wicket.ng.resource.IResource.Attributes) returns true and setErrorCode(Integer) has not been called.

Parameters:
writeCallback -

getWriteCallback

public AbstractResource.WriteCallback getWriteCallback()
Returns:
write callback.


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