|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WResource
public abstract class WResource
An object which can be rendered in the HTTP protocol.
WAnchor or
WImage can use a resource instead of a URL to provide their contents.
Whenever the resource has changed, you should call the setChanged() method.
setChanged() will make sure that the browser will use a new version of the
resource by generating a new URL, and emits the dataChanged() signal to make
those that refer to the resource aware that they should update their
references to the new URL.
You can help the browser to start a suitable helper application to handle the
resource, or suggest to the user a suitable filename for saving the resource,
by setting an appropriate file name using suggestFileName(String).
To serve resources that you create on the fly, you need to specialize this
class and reimplement handleRequest(WebRequest, WebResponse).
WAnchor,
WImage| Nested Class Summary | |
|---|---|
static class |
WResource.DispositionType
Values for the disposition type in the Content-Disposition header |
| Constructor Summary | |
|---|---|
|
WResource()
Constructor. |
protected |
WResource(WObject parent)
|
| Method Summary | |
|---|---|
Signal |
dataChanged()
Signal triggered when the data presented in this resource has changed. |
Signal2<java.lang.Long,java.lang.Long> |
dataReceived()
Signal emitted when data has been received for this resource. |
java.lang.String |
generateUrl()
Generates a URL for this resource. |
WResource.DispositionType |
getDispositionType()
Returns the currently configured content disposition |
java.lang.String |
getInternalPath()
Returns the internal path. |
java.lang.String |
getSuggestedFileName()
Returns the suggested file name. |
java.lang.String |
getUrl()
Returns the current URL for this resource. |
protected abstract void |
handleRequest(WebRequest request,
WebResponse response)
Handles a request. |
void |
setChanged()
Generates a new URL for this resource and emits the changed signal |
void |
setDispositionType(WResource.DispositionType dispositionType)
Configures the Content-Disposition header The Content-Disposition header allows to instruct the browser that a resource should be shown inline or as attachment. |
void |
setInternalPath(java.lang.String internalPath)
Sets an internal path for this resource. |
void |
setUploadProgress(boolean enabled)
Indicate interest in upload progress. |
void |
suggestFileName(java.lang.String name)
Suggests a filename to the user for the data streamed by this resource. |
void |
suggestFileName(java.lang.String name,
WResource.DispositionType dispositionType)
Suggests a filename to the user for the data streamed by this resource. |
void |
write(java.io.OutputStream out)
Writes the resource to an output stream. |
void |
write(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String[]> parameterMap,
java.util.Map<java.lang.String,java.util.List<UploadedFile>> uploadedFiles)
Writes the resource to an output stream. |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected WResource(WObject parent)
public WResource()
| Method Detail |
|---|
public java.lang.String generateUrl()
The url is unique to assure that it is not cached by the web browser, and
can thus be used to refer to a new "version" of the resource, which can
be indicated by triggering the dataChanged() signal.
The old urls are not invalidated by calling this method.
protected abstract void handleRequest(WebRequest request,
WebResponse response)
throws java.io.IOException
Reimplement this method so that a proper response is generated for the given request. From the request object you can access request parameters and whether the request is a continuation request. In the response object, you should set the mime type and stream the output data.
request - The request informationresponse - The response object
java.io.IOExceptionpublic Signal dataChanged()
Widgets that reference the resource (such as anchors and images) will
make sure the new data is rendered.
It is better to call setChanged() than to trigger this signal
since that method generates a new URL for this resource to avoid caching problems
before emitting the signal.
public void write(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String[]> parameterMap,
java.util.Map<java.lang.String,java.util.List<UploadedFile>> uploadedFiles)
throws java.io.IOException
This is a utility method that allows you to write the resource to an
output stream, by using handleRequest(WebRequest, WebResponse).
out - The output stream.parameterMap - A map with parameters that are made available in the
WebRequest.uploadedFiles - A list of uploaded files that are made available in the
WebRequest.
java.io.IOException
public void write(java.io.OutputStream out)
throws java.io.IOException
This is a utility method that allows you to write the resource to an
output stream, by using handleRequest(WebRequest, WebResponse).
out - The output stream.
java.io.IOException
public void suggestFileName(java.lang.String name,
WResource.DispositionType dispositionType)
For resources, intended to be downloaded by the user, suggest a name used for saving. The filename extension may also help the browser to identify the correct program for opening the resource. The disposition type determines if the resource is intended to be opened by a plugin in the browser (DispositionType#Inline), or to be saved to disk (DispositionType#Attachment). DispositionType#NoDisposition is not a valid Content-Disposition when a filename is suggested; this will be rendered as DispositionType#Attachment.
setDispositionType(DispositionType dispositionType)public void suggestFileName(java.lang.String name)
For resources, intended to be downloaded by the user, suggest a name used for saving. The filename extension may also help the browser to identify the correct program for opening the resource. The disposition type determines if the resource is intended to be opened by a plugin in the browser (DispositionType#Inline), or to be saved to disk (DispositionType#Attachment). DispositionType#NoDisposition is not a valid Content-Disposition when a filename is suggested; this will be rendered as DispositionType#Attachment.
Calls {@link #suggestFileName(String name, DispositionType dispositionType)
suggestFileName(name, DispositionType.Attachment) }public java.lang.String getSuggestedFileName()
suggestFileName(String)public void setChanged()
public void setDispositionType(WResource.DispositionType dispositionType)
suggestFileName(String, DispositionType). The
Content-Disposition must not be DispositionType#NoDisposition
when a filename is given; if this case is encountered, None will be
rendered as DispositionType#Attachment.
suggestFileName(String, DispositionType)public WResource.DispositionType getDispositionType()
setDispositionType(DispositionType cd)public java.lang.String getUrl()
public java.lang.String getInternalPath()
setInternalPath(String)public void setInternalPath(java.lang.String internalPath)
WApplication.setInternalPath(String)), if you
do not want a conflict between these two when the browser does not use
AJAX (and thus url fragments for its internal paths).
The default value is empty. By default the URL for a resource is
unspecified and a URL will be generated by the library.
public void setUploadProgress(boolean enabled)
handleRequest(WebRequest
request, WebResponse response) is called, progress information is
indicated using dataReceived().
The default value is false.
public Signal2<java.lang.Long,java.lang.Long> dataReceived()
WTimer.
setUploadProgress(boolean enabled)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||