The ViewLoader component can be used to load new Smart GWT-based user interfaces into a running application.
NOTE: before using a ViewLoader, be sure that you have read about and understood the
com.smartgwt.client.docs.SmartArchitecture. The most responsive and scalable application
architecture preloads views rather than using ViewLoaders.
A ViewLoader is a Canvas, and can be provided anywhere a
Canvas can be provided: as a Tab pane, and Layout member, etc. When a ViewLoader draws, it shows a
com.smartgwt.client.widgets.ViewLoader#getLoadingMessage, then performs an RPC to the
com.smartgwt.client.widgets.ViewLoader#getViewURL to load components.
The response from the viewURL should
be Smart GWT components defined in JavaScript, with no surrounding <SCRIPT> tags or other HTML framing. The
returned script can be dynamically generated, for example, it may be the result of a JSP containing an XML view
description enclosed in
com.smartgwt.client.docs.XmlTag tags.
In the returned script,
the special variable "viewLoader" is available to refer to the ViewLoader instance that is loading components. The
intended usage is that the returned script creates a view consisting of Smart GWT components, then calls
viewLoader.setView(myView)
to place the loaded view into the ViewLoader. If the view does not call
setView() explicitly, the viewLoader will find the last top-level UI component (Canvas subclass) created by the view and
set that as the current view. Top-level in this case means that the UI component is not contained in another UI
component as a member or child.
The ViewLoader relies on the XMLHttpRequest object which can be disabled by
end-users in some supported browsers. See
com.smartgwt.client.docs.PlatformDependencies for more information.