com.smartgwt.client.widgets
Class ViewLoader

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.smartgwt.client.widgets.BaseWidget
              extended by com.smartgwt.client.widgets.Canvas
                  extended by com.smartgwt.client.widgets.StatefulCanvas
                      extended by com.smartgwt.client.widgets.Button
                          extended by com.smartgwt.client.widgets.Label
                              extended by com.smartgwt.client.widgets.ViewLoader
All Implemented Interfaces:
HasHandlers, EventListener, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasIconClickHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasScrolledHandlers, HasShowContextMenuHandlers

public class ViewLoader
extends Label

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 'Smart GWT Architecture'. 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 'loading message', then performs an RPC to the 'viewURL' 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 '<isomorphicXML>' 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 PlatformDependencies for more information.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.smartgwt.client.widgets.BaseWidget
config, configOnly, id, isElementSet, scClassName
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ViewLoader()
           
ViewLoader(JavaScriptObject jsObj)
           
 
Method Summary
protected  JavaScriptObject create()
           
 Boolean getAllowCaching()
          By default a ViewLoader will explicitly prevent browser caching.
 String getHttpMethod()
          Selects the HTTP method that will be used when fetching content.
 String getLoadingMessage()
          Message to show while the view is loading
static ViewLoader getOrCreateRef(JavaScriptObject jsObj)
           
 Canvas getView()
          Retrieve the current view.
 String getViewURL()
          URL to load components from.
 void setAllowCaching(Boolean allowCaching)
          By default a ViewLoader will explicitly prevent browser caching.
 void setHttpMethod(String httpMethod)
          Selects the HTTP method that will be used when fetching content.
 void setLoadingMessage(String loadingMessage)
          Message to show while the view is loading
 void setViewURL(String viewURL)
          URL to load components from.
 void viewLoaded(Canvas view)
          StringMethod fired when the view has been loaded.
 
Methods inherited from class com.smartgwt.client.widgets.Label
getAlign, getAutoFit, getContents, getDynamicContents, getIcon, getIconAlign, getIconHeight, getIconOrientation, getIconSize, getIconSpacing, getIconWidth, getShowDisabledIcon, getShowDownIcon, getShowFocusedIcon, getShowRollOverIcon, getShowSelectedIcon, getValign, getWrap, setAlign, setAutoFit, setContents, setDynamicContents, setIcon, setIconAlign, setIconHeight, setIconOrientation, setIconSize, setIconSpacing, setIconWidth, setShowDisabledIcon, setShowDownIcon, setShowFocusedIcon, setShowRollOverIcon, setShowSelectedIcon, setValign, setWrap
 
Methods inherited from class com.smartgwt.client.widgets.Button
action, addIconClickHandler, addToRadioGroup, deselect, getActionType, getBaseStyle, getHiliteAccessKey, getRadioGroup, getSelected, getShowDisabled, getShowDown, getShowFocused, getShowRollOver, getState, getTitle, isSelected, removeFromRadioGroup, removeFromRadioGroup, select, setActionType, setBaseStyle, setDisabled, setHiliteAccessKey, setRadioGroup, setSelected, setShowDisabled, setShowDown, setShowFocused, setShowRollOver, setState, setTitle, setVAlign
 
Methods inherited from class com.smartgwt.client.widgets.StatefulCanvas
getOverCanvasConstructor, getRedrawOnStateChange, getShowFocusedAsOver, getShowOverCanvas, getStateSuffix, setOverCanvasConstructor, setRedrawOnStateChange, setShowFocusedAsOver, setShowOverCanvas, setTitleStyle
 
Methods inherited from class com.smartgwt.client.widgets.Canvas
addChild, addChild, addChild, addClickHandler, addDoubleClickHandler, addDragMoveHandler, addDragRepositionMoveHandler, addDragRepositionStartHandler, addDragRepositionStopHandler, addDragResizeMoveHandler, addDragResizeStartHandler, addDragResizeStopHandler, addDragStartHandler, addDragStopHandler, addDropHandler, addDropMoveHandler, addDropOutHandler, addDropOverHandler, addFocusChangedHandler, addHoverHandler, addHoverHiddenHandler, addKeyDownHandler, addKeyPressHandler, addMouseDownHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseStillDownHandler, addMouseUpHandler, addMouseWheelHandler, addPeer, addPeer, addResizedHandler, addRightMouseDownHandler, addScrolledHandler, addShowContextMenuHandler, addStyleName, adjustForContent, animateFade, animateFade, animateFade, animateHide, animateHide, animateHide, animateMove, animateMove, animateMove, animateMove, animateRect, animateRect, animateRect, animateResize, animateResize, animateResize, animateScroll, animateScroll, animateScroll, animateShow, animateShow, animateShow, blur, bringToFront, clear, clickMaskUp, clickMaskUp, contains, contains, containsEvent, containsFocus, containsPoint, containsPoint, convertToCanvasArray, disable, enable, focus, getAbsoluteLeft, getAbsoluteTop, getAccessKey, getAnimateAcceleration, getAnimateFadeTime, getAnimateHideAcceleration, getAnimateHideTime, getAnimateMoveAcceleration, getAnimateMoveTime, getAnimateRectAcceleration, getAnimateRectTime, getAnimateResizeAcceleration, getAnimateResizeTime, getAnimateScrollAcceleration, getAnimateScrollTime, getAnimateShowAcceleration, getAnimateShowTime, getAnimateTime, getAppImgDir, getAutoShowParent, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorder, getBottom, getById, getCanAcceptDrop, getCanDrag, getCanDragReposition, getCanDragResize, getCanDragScroll, getCanDrop, getCanDropBefore, getCanFocus, getCanHover, getCanSelectText, getChildren, getChildrenSnapResizeToGrid, getChildrenSnapToGrid, getContextMenu, getCursor, getDataPath, getDefaultHeight, getDefaultWidth, getDestroyed, getDestroying, getDisabled, getDisabledCursor, getDoubleClickDelay, getDragAppearance, getDragIntersectStyle, getDragOpacity, getDragRepositionCursor, getDragScrollDelay, getDragStartDistance, getDragTarget, getDragType, getEdgeBackgroundColor, getEdgeCenterBackgroundColor, getEdgeImage, getEdgeOffset, getEdgeOpacity, getEdgeShowCenter, getEdgeSize, getExtraSpace, getFullDataPath, getGroupTitle, getHeight, getHeightAsString, getHoverAlign, getHoverDelay, getHoverHeight, getHoverHTML, getHoverMoveWithMouse, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getHoverWrap, getHSnapOrigin, getHSnapOrigin, getHSnapPosition, getHSnapPosition, getHtmlPosition, getImgURL, getImgURL, getInnerContentHeight, getInnerContentWidth, getInnerHeight, getInnerWidth, getIsGroup, getLeft, getLeftAsString, getMargin, getMatchElement, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getMouseStillDownDelay, getMouseStillDownInitialDelay, getNextZIndex, getNoDoubleClicks, getOffsetHeight, getOffsetWidth, getOffsetX, getOffsetY, getOpacity, getOverflow, getPadding, getPageBottom, getPageLeft, getPageRect, getPageRight, getPageTop, getParentElement, getPercentBox, getPosition, getPrefix, getPrompt, getRect, getRedrawOnResize, getResizeBarTarget, getRight, getScrollbarSize, getScrollBottom, getScrollHeight, getScrollLeft, getScrollRight, getScrollTop, getScrollWidth, getShadowDepth, getShadowImage, getShadowOffset, getShadowSoftness, getShowCustomScrollbars, getShowDragShadow, getShowEdges, getShowHover, getShowResizeBar, getShowShadow, getSkinImgDir, getSnapAxis, getSnapEdge, getSnapHDirection, getSnapHGap, getSnapOffsetLeft, getSnapOffsetTop, getSnapOnDrop, getSnapResizeToGrid, getSnapTo, getSnapToGrid, getSnapVDirection, getSnapVGap, getStyleName, getTabIndex, getTooltip, getTop, getTopAsString, getValuesManager, getViewportHeight, getViewportWidth, getVisibility, getVisibleHeight, getVisibleWidth, getVSnapOrigin, getVSnapOrigin, getVSnapPosition, getVSnapPosition, getWidth, getWidthAsString, getZIndex, handleHover, hide, hideClickMask, hideClickMask, hideContextMenu, imgHTML, imgHTML, imgHTML, intersects, isDirty, isDisabled, isDrawn, isVisible, keyUp, layoutChildren, linkHTML, linkHTML, markForDestroy, markForRedraw, markForRedraw, moveAbove, moveBelow, moveBy, moveTo, parentResized, redraw, redraw, removeChild, removeChild, resizeBy, resizeTo, resizeTo, scrollBy, scrollByPercent, scrollTo, scrollTo, scrollToBottom, scrollToLeft, scrollToPercent, scrollToRight, scrollToTop, sendToBack, setAccessKey, setAnimateAcceleration, setAnimateFadeTime, setAnimateHideAcceleration, setAnimateHideTime, setAnimateMoveAcceleration, setAnimateMoveTime, setAnimateRectAcceleration, setAnimateRectTime, setAnimateResizeAcceleration, setAnimateResizeTime, setAnimateScrollAcceleration, setAnimateScrollTime, setAnimateShowAcceleration, setAnimateShowTime, setAnimateTime, setAppImgDir, setAutoHeight, setAutoShowParent, setAutoWidth, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBottom, setCanAcceptDrop, setCanDrag, setCanDragReposition, setCanDragResize, setCanDragScroll, setCanDrop, setCanDropBefore, setCanFocus, setCanHover, setCanSelectText, setChildren, setChildrenSnapResizeToGrid, setChildrenSnapToGrid, setContextMenu, setCursor, setDataPath, setDefaultHeight, setDefaultWidth, setDisabledCursor, setDoubleClickDelay, setDragAppearance, setDragIntersectStyle, setDragOpacity, setDragRepositionCursor, setDragScrollDelay, setDragStartDistance, setDragTarget, setDragType, setDropTypes, setEdgeBackgroundColor, setEdgeCenterBackgroundColor, setEdgeImage, setEdgeMarginSize, setEdgeOffset, setEdgeOpacity, setEdgeShowCenter, setEdgeSize, setExtraSpace, setGroupTitle, setHeight, setHeight, setHeight100, setHoverAlign, setHoverDelay, setHoverHeight, setHoverMoveWithMouse, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setHoverWrap, setHtmlPosition, setImage, setImage, setIsGroup, setKeepInParentRect, setKeepInParentRect, setLayoutAlign, setLayoutAlign, setLeft, setLeft, setMargin, setMatchElement, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setMouseStillDownDelay, setMouseStillDownInitialDelay, setNoDoubleClicks, setOpacity, setOverflow, setPadding, setPageLeft, setPageTop, setParentElement, setPercentBox, setPosition, setPrefix, setPrompt, setRect, setRect, setRedrawOnResize, setResizeBarTarget, setResizeFrom, setRight, setScrollbarSize, setShadowDepth, setShadowImage, setShadowOffset, setShadowSoftness, setShowCustomScrollbars, setShowDragShadow, setShowEdges, setShowHover, setShowResizeBar, setShowShadow, setSkinImgDir, setSmoothFade, setSnapAxis, setSnapEdge, setSnapHDirection, setSnapHGap, setSnapOffsetLeft, setSnapOffsetTop, setSnapOnDrop, setSnapResizeToGrid, setSnapTo, setSnapToGrid, setSnapVDirection, setSnapVGap, setStyleName, setTabIndex, setTooltip, setTop, setTop, setValuesManager, setVisibility, setVisible, setWidth, setWidth, setWidth100, setZIndex, shouldDragScroll, show, showClickMask, showNextTo, showNextTo, showPrintPreview, updateHover, updateHover, updateShadow, visibleAtPoint, visibleAtPoint, willAcceptDrop
 
Methods inherited from class com.smartgwt.client.widgets.BaseWidget
addDrawHandler, destroy, doAddHandler, doInit, doOnRender, draw, equals, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getConfig, getDOM, getElement, getElement, getHandlerCount, getID, getInnerHTML, getJsObj, getOrCreateJsObj, getRef, hashCode, isConfigOnly, isCreated, onDestroy, onDraw, onInit, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setDragTracker, setElement, setHtmlElement, setID, setNullProperty, setPosition, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getStyleElement, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setPixelSize, setSize, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

ViewLoader

public ViewLoader()

ViewLoader

public ViewLoader(JavaScriptObject jsObj)
Method Detail

getOrCreateRef

public static ViewLoader getOrCreateRef(JavaScriptObject jsObj)

create

protected JavaScriptObject create()
Overrides:
create in class Label

setLoadingMessage

public void setLoadingMessage(String loadingMessage)
                       throws IllegalStateException
Message to show while the view is loading

Parameters:
loadingMessage - loadingMessage Default value is "Loading View..."
Throws:
IllegalStateException - this property cannot be changed after the component has been created

getLoadingMessage

public String getLoadingMessage()
Message to show while the view is loading

Returns:
String

setViewURL

public void setViewURL(String viewURL)
                throws IllegalStateException
URL to load components from. Change the URL this component loads a view from. Triggers a fetch from the new URL.

Can also be called with no arguments to reload the view from the existing viewURL.

Parameters:
viewURL - URL to retrieve view from. Default value is null
Throws:
IllegalStateException - this property cannot be changed after the component has been created

getViewURL

public String getViewURL()
URL to load components from.

Returns:
String

setHttpMethod

public void setHttpMethod(String httpMethod)
Selects the HTTP method that will be used when fetching content. Valid values are "POST" and "GET".

Parameters:
httpMethod - httpMethod Default value is "GET"

getHttpMethod

public String getHttpMethod()
Selects the HTTP method that will be used when fetching content. Valid values are "POST" and "GET".

Returns:
String

setAllowCaching

public void setAllowCaching(Boolean allowCaching)
                     throws IllegalStateException
By default a ViewLoader will explicitly prevent browser caching.

Set to true to allow browser caching if the browser would normally do so, in other words, if the HTTP headers returned with the response indicate that the response can be cached.

Parameters:
allowCaching - allowCaching Default value is false
Throws:
IllegalStateException - this property cannot be changed after the component has been created

getAllowCaching

public Boolean getAllowCaching()
By default a ViewLoader will explicitly prevent browser caching.

Set to true to allow browser caching if the browser would normally do so, in other words, if the HTTP headers returned with the response indicate that the response can be cached.

Returns:
Boolean

getView

public Canvas getView()
Retrieve the current view. May be null if the view has not yet been loaded, or has been explicitly set to null.

Returns:
the current view

viewLoaded

public void viewLoaded(Canvas view)
StringMethod fired when the view has been loaded. Has no default implementation. May be observed or overridden to fire custom logic when loading completes.

Parameters:
view - the view that was loaded