public interface AsyncXmlLoader
If you want to develop a GWT application which runs as a
regular web application, you do not need this level of
abstraction and can use the HttpRequestXmlLoader class
directly with no specific configuration.
If you want to develop a GWT application which can be run either as a regular web application or as a plasmoid / opera control, you will create instances of this type by calling:
AsyncXmlLoader loader = GWT.create(AsyncXmlLoader.class)then use the proper GWT configuration to control which implementation gets instantiated.
For regular web application, use HttpRequestXmlLoader:
<replace-with class="org.vectomatic.dom.svg.utils.HttpRequestXmlLoader"> <when-type-is class="org.vectomatic.dom.svg.utils.AsyncXmlLoader" /> </replace-with>
For plasmoids / opera controls, use IFrameXmlLoader:
<replace-with class="org.vectomatic.dom.svg.utils.IFrameXmlLoader"> <when-type-is class="org.vectomatic.dom.svg.utils.AsyncXmlLoader" /> </replace-with>
For instance, if you want to load an SVG image located in the public directory of your GWT application, you should make the following call:
AsyncXmlLoader loader = ...;
String resourceName = "foo.svg";
loader.loadResource(GWT.getModuleBaseURL() + "/" + resourceName, new AsyncXmlLoaderCallback() {
public void onSuccess(String resourceName, Element root) {
RootPanel.get().add(new SVGImage(OMNode.<OMSVGSVGElement>convert(root)));
}
public void onError(String resourceName, Throwable error) {
GWT.log("Cannot load " + resourceName, error);
}
});
| Modifier and Type | Method and Description |
|---|---|
void |
loadResource(String resourceUrl,
AsyncXmlLoaderCallback callback)
Initiates a request to load an XML resource
|
void loadResource(String resourceUrl, AsyncXmlLoaderCallback callback)
resourceUrl - The resource to loadcallback - A callback invoked to process the resource once it is loadedCopyright © 2018. All Rights Reserved.