org.vectomatic.dom.svg.utils
Interface AsyncXmlLoader

All Known Implementing Classes:
HttpRequestXmlLoader, IFrameXmlLoader

public interface AsyncXmlLoader

Interface to define an API to load XML resources asynchronously.

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);
        }
 });
 


Method Summary
 void loadResource(String resourceUrl, AsyncXmlLoaderCallback callback)
          Initiates a request to load an XML resource
 

Method Detail

loadResource

void loadResource(String resourceUrl,
                  AsyncXmlLoaderCallback callback)
Initiates a request to load an XML resource

Parameters:
resourceUrl - The resource to load
callback - A callback invoked to process the resource once it is loaded


Copyright © 2012. All Rights Reserved.