|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maryanovsky.gwtutils.client.net.AbstractResponseHandler
com.maryanovsky.gwtutils.client.net.XmlResponseHandler<T>
public class XmlResponseHandler<T>
A base implementation of a RequestCallback
which handles XML
responses. An XmlResponseHandler
can be either parameterized by a
parser and a callback to parse and handle the response XML document or by
subclassing and overriding the appropriate method. See the constructor(s) for
more information.
Field Summary |
---|
Fields inherited from class com.maryanovsky.gwtutils.client.net.AbstractResponseHandler |
---|
requestUrl |
Constructor Summary | |
---|---|
XmlResponseHandler(String requestUrl,
String successfulResponseTagName,
String errorResponseTagName,
XmlParser<T> parser,
ResultCallback<T> callback)
Creates a new XmlResponseHandler with the specified arguments. |
Method Summary | |
---|---|
protected String |
getRequestUrl()
Returns the request URL. |
protected void |
onAnyResponse()
Invoked whenever any kind of response arrives, before any of the other methods. |
protected void |
onBadlyFormedXml(Response response,
DOMException e)
Invoked when the result could not be parsed as an XML document. |
protected void |
onBadResponse(Document document,
ParseException e)
Invoked when the received response cannot be parsed by parseResponse(Document) . |
protected void |
onErrorXmlResponse(Document document)
Invoked when an error response arrives. |
protected void |
onResult(T result)
Invoked when a response successfully parsed by parseResponse(Document) arrives. |
protected void |
onSuccessfulResponse(Response response)
Invoked when a successful response arrives. |
protected void |
onSuccessfulXmlResponse(Document document)
Invoked when a successful XML response arrives. |
protected void |
onUnrecognizedResponse(Document document)
Invoked when an unknown response arrives (a document whose main tag name is not recognized). |
protected T |
parseResponse(Document document)
Parses the specified response and returns the resulting object. |
protected void |
showErrorMessage(String errorMessage)
Displays the specified error message. |
Methods inherited from class com.maryanovsky.gwtutils.client.net.AbstractResponseHandler |
---|
onError, onRequestError, onResponseReceived, onUnexpectedStatusCode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlResponseHandler(String requestUrl, String successfulResponseTagName, String errorResponseTagName, XmlParser<T> parser, ResultCallback<T> callback)
XmlResponseHandler
with the specified arguments.
If parser
is not null
, the default
implementation of parseResponse(Document)
will use it to parse
the received XML document; otherwise, it will return the document itself
as the result. This means that T
must be
Document
if parser
is null
and
parseResponse(Document)
is not overridden.
If callback
is not null
,
onAnyResponse()
and onResult(Object)
will invoke the
appropriate method on it.
requestUrl
- The URL of the request.successfulResponseTagName
- The name of the document's main tag in
case of a successful response.errorResponseTagName
- The name of the document's main tag in case
of an error response.parser
- The parser we use to parse the response XML document; may
be null
.callback
- The callback to notify when a response/result arrives;
may be null
.Method Detail |
---|
protected String getRequestUrl()
protected void onSuccessfulResponse(Response response)
onSuccessfulXmlResponse(Document)
,
onErrorXmlResponse(Document)
or
onUnrecognizedResponse(Document)
depending on the root tag name
of the response document. If the response could not be parsed as an XML
document, invoked onBadlyFormedXml(Response, DOMException)
.
onSuccessfulResponse
in class AbstractResponseHandler
protected void onBadlyFormedXml(Response response, DOMException e)
protected T parseResponse(Document document) throws ParseException
ParseException
. The default
implementation returns uses the parser passed to the constructor to
parse the response. If the parser is null
, returns the
document itself.
ParseException
protected void onSuccessfulXmlResponse(Document document)
onResult(Object)
.
protected void onErrorXmlResponse(Document document)
protected void onUnrecognizedResponse(Document document)
protected void onBadResponse(Document document, ParseException e)
parseResponse(Document)
. The default implementation shows an
error message.
document
- The response document.e
- The exception thrown when parsing the response.protected void onAnyResponse()
ResultCallback.requestFinished()
on the callback, if any.
onAnyResponse
in class AbstractResponseHandler
protected void onResult(T result)
parseResponse(Document)
arrives. The default implementation
invokes ResultCallback.resultReceived(Object)
on the callback, if
any.
result
- The object returned by parseResponse(Document)
.protected void showErrorMessage(String errorMessage)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |