Class HTMLPane

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasContentLoadedHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers

public class HTMLPane extends HTMLFlow
Subclass of HTMLFlow configured to display HTML content in a pane of specified size. If the HTML content is larger than the size of the pane, the pane will provide scrollbars for viewing clipped content.

HTML content can be specified directly via contents, or loaded from a URL via the property contentsURL. This method of loading is for simple HTML content only; Smart GWT components should be loaded via the ViewLoader class.

HTMLPanes have the ability to render snippets of HTML directly in the document, or use an IFRAME to render a complete HTML page. See contentsType for more information

You can set the size of an HTMLPane directly via the width and height properties, or indirectly by placing the HTMLPane in a container component (Layout, Window, SectionStack, etc) that manages the sizes of its members.

  • Constructor Details

    • HTMLPane

      public HTMLPane()
    • HTMLPane

      public HTMLPane(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static HTMLPane getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class HTMLFlow
    • setAutoDeriveContentsType

      public HTMLPane setAutoDeriveContentsType(boolean autoDeriveContentsType)
      If ContentsType is not explicitly specified, should it be automatically derived?

      If set to true, this component will use isPageHTML() to determine whether the contents are a standalone HTML page which should be rendered into an embedded IFRAME rather than written directly into the component's handle in the DOM.

      Note that this property will auto derive the appropriate contents type for both explicitly specified contents and for HTML loaded from the contentsURL

      See ContentsType for further information on displaying complete HTML pages in an IFRAME.

      Overrides:
      setAutoDeriveContentsType in class HTMLFlow
      Parameters:
      autoDeriveContentsType - New autoDeriveContentsType value. Default value is false
      Returns:
      HTMLPane instance, for chaining setter calls
    • getAutoDeriveContentsType

      public boolean getAutoDeriveContentsType()
      If ContentsType is not explicitly specified, should it be automatically derived?

      If set to true, this component will use isPageHTML() to determine whether the contents are a standalone HTML page which should be rendered into an embedded IFRAME rather than written directly into the component's handle in the DOM.

      Note that this property will auto derive the appropriate contents type for both explicitly specified contents and for HTML loaded from the contentsURL

      See ContentsType for further information on displaying complete HTML pages in an IFRAME.

      Overrides:
      getAutoDeriveContentsType in class HTMLFlow
      Returns:
      Current autoDeriveContentsType value. Default value is false
    • setContents

      public HTMLPane setContents(String contents)
      String of HTML contents for this component - may be a fragment of HTML to display or a complete HTML page. See HTMLFlow.contentsType and HTMLFlow.supportsContentsAsPage.

      To load HTML contents from a URL, use HTMLFlow.contentsURL instead of this property. If contentsURL is non-null, contents will be ignored.

      Overrides:
      setContents in class HTMLFlow
      Parameters:
      contents - New contents value. Default value is " "
      Returns:
      HTMLPane instance, for chaining setter calls
      See Also:
    • getContents

      public String getContents()
      String of HTML contents for this component - may be a fragment of HTML to display or a complete HTML page. See HTMLFlow.contentsType and HTMLFlow.supportsContentsAsPage.

      To load HTML contents from a URL, use HTMLFlow.contentsURL instead of this property. If contentsURL is non-null, contents will be ignored.

      Overrides:
      getContents in class HTMLFlow
      Returns:
      Current contents value. Default value is " "
      See Also:
    • setContentsType

      public HTMLPane setContentsType(ContentsType contentsType)
      The contentsType attribute governs whether the contents of this htmlFlow are a fragment of HTML to inserted directly into the DOM, or a complete HTML page to be displayed in an IFRAME. If not explicitly specified, autoDeriveContentsType may be set to automatically determine the appropriate contents type by analyzing the contents of the component. If autoDeriveContentsType is false and contentsType is not explicitly specified, contents will always be assumed to be "fragment".

      HTMLFlow contents may be directly specified or loaded from a specified URL. Note that if supportsContentsAsPage is false and no contentsURL is specified, the contents string will always be assumed to be a fragment, even if ContentsType is explicitly set to "page".

      Note that an HTMLFlow with contentsType:"page" should not be used to load and display a page containing a set of Smart GWT components into the application. To dynamically load Smart GWT components, use ViewLoader, never this mechanism (click here for why).

      Scripting, CSS and scoping considerations for HTMLFlow contents
      The following considerations apply to HTMLFlow contents, whether directly specified or loaded from a contentsURL.

      When contentsType is "page", the HTML content will be rendered as a standalone document using an IFRAME. Use iframeSandbox to specify IFRAME restrictions using the native sandbox attribute. Note that any script (if allowed) will be executed in the scope of the embedded IFRAME window, not the main application window. Similarly, other features like css stylesheets loaded by the HTMLFlow will apply to the IFRAME window only, and the IFRAME will not pick up css style from the main application by default.

      When contentsType is "fragment", if script is encountered within the HTML fragment it will be evaluated in the scope of the main application if evalScriptBlocks is enabled. Developers should be aware that this evaluation occurs as part of the draw/redraw process, but unlike script embedded directly in a static HTML page, it is not processed by the browser while the elements are being written into the DOM and document.write(...) can not be used to modify the HTML as it is being rendered. In this mode, since the contents is written directly into the DOM, standard css styling for the page will be applied.

      Note that if autoDeriveContentsType is enabled, the default set of recognized structuralHTMLTags include <script&gt, so HTML contents including script will display as contentsType:"page". The list of structuralHTMLTags can be modified to exclude script tags if desired.

      Overrides:
      setContentsType in class HTMLFlow
      Parameters:
      contentsType - New contentsType value. Default value is null
      Returns:
      HTMLPane instance, for chaining setter calls
    • getContentsType

      public ContentsType getContentsType()
      The contentsType attribute governs whether the contents of this htmlFlow are a fragment of HTML to inserted directly into the DOM, or a complete HTML page to be displayed in an IFRAME. If not explicitly specified, autoDeriveContentsType may be set to automatically determine the appropriate contents type by analyzing the contents of the component. If autoDeriveContentsType is false and contentsType is not explicitly specified, contents will always be assumed to be "fragment".

      HTMLFlow contents may be directly specified or loaded from a specified URL. Note that if supportsContentsAsPage is false and no contentsURL is specified, the contents string will always be assumed to be a fragment, even if ContentsType is explicitly set to "page".

      Note that an HTMLFlow with contentsType:"page" should not be used to load and display a page containing a set of Smart GWT components into the application. To dynamically load Smart GWT components, use ViewLoader, never this mechanism (click here for why).

      Scripting, CSS and scoping considerations for HTMLFlow contents
      The following considerations apply to HTMLFlow contents, whether directly specified or loaded from a contentsURL.

      When contentsType is "page", the HTML content will be rendered as a standalone document using an IFRAME. Use iframeSandbox to specify IFRAME restrictions using the native sandbox attribute. Note that any script (if allowed) will be executed in the scope of the embedded IFRAME window, not the main application window. Similarly, other features like css stylesheets loaded by the HTMLFlow will apply to the IFRAME window only, and the IFRAME will not pick up css style from the main application by default.

      When contentsType is "fragment", if script is encountered within the HTML fragment it will be evaluated in the scope of the main application if evalScriptBlocks is enabled. Developers should be aware that this evaluation occurs as part of the draw/redraw process, but unlike script embedded directly in a static HTML page, it is not processed by the browser while the elements are being written into the DOM and document.write(...) can not be used to modify the HTML as it is being rendered. In this mode, since the contents is written directly into the DOM, standard css styling for the page will be applied.

      Note that if autoDeriveContentsType is enabled, the default set of recognized structuralHTMLTags include <script&gt, so HTML contents including script will display as contentsType:"page". The list of structuralHTMLTags can be modified to exclude script tags if desired.

      Overrides:
      getContentsType in class HTMLFlow
      Returns:
      Current contentsType value. Default value is null
    • setContentsURL

      public HTMLPane setContentsURL(String contentsURL)
      If specified the HTMLFlow will load its contents from this URL instead of displaying this.contents. May be combined with parameters if contentsURLParams were specified.

      The HTML retrieved from the target URL may be a complete standalone page to be rendered into its own scope using an IFRAME, or a fragment of HTML to display within this component's handle. See ContentsType and autoDeriveContentsType for more information.

      Note that the link{loadingMessage} and httpMethod features only apply if contentsURL was set and contentsType was not explicitly set to "page"

      Overrides:
      setContentsURL in class HTMLFlow
      Parameters:
      contentsURL - New contentsURL value. Default value is null
      Returns:
      HTMLPane instance, for chaining setter calls
      See Also:
    • getContentsURL

      public String getContentsURL()
      If specified the HTMLFlow will load its contents from this URL instead of displaying this.contents. May be combined with parameters if contentsURLParams were specified.

      The HTML retrieved from the target URL may be a complete standalone page to be rendered into its own scope using an IFRAME, or a fragment of HTML to display within this component's handle. See ContentsType and autoDeriveContentsType for more information.

      Note that the link{loadingMessage} and httpMethod features only apply if contentsURL was set and contentsType was not explicitly set to "page"

      Overrides:
      getContentsURL in class HTMLFlow
      Returns:
      Current contentsURL value. Default value is null
      See Also:
    • setDefaultHeight

      public HTMLPane setDefaultHeight(int defaultHeight)
      Default height for the component.

      For a component that should potentially be sized automatically by a Layout, set this property rather than height directly, because Layouts regard a height setting as an explicit size that shouldn't be changed.

      Note : This is an advanced setting

      Overrides:
      setDefaultHeight in class HTMLFlow
      Parameters:
      defaultHeight - New defaultHeight value. Default value is 200
      Returns:
      HTMLPane instance, for chaining setter calls
      See Also:
    • getDefaultHeight

      public int getDefaultHeight()
      Default height for the component.

      For a component that should potentially be sized automatically by a Layout, set this property rather than height directly, because Layouts regard a height setting as an explicit size that shouldn't be changed.

      Overrides:
      getDefaultHeight in class HTMLFlow
      Returns:
      Current defaultHeight value. Default value is 200
      See Also:
    • setOverflow

      public HTMLPane setOverflow(Overflow overflow)
      HTMLPanes are overflow:"auto" by default.

      Note that for contentsType:"page", overflow:"visible" is not supported.

      Overrides:
      setOverflow in class HTMLFlow
      Parameters:
      overflow - New overflow value. Default value is Canvas.AUTO
      Returns:
      HTMLPane instance, for chaining setter calls
      See Also:
    • getOverflow

      public Overflow getOverflow()
      HTMLPanes are overflow:"auto" by default.

      Note that for contentsType:"page", overflow:"visible" is not supported.

      Overrides:
      getOverflow in class HTMLFlow
      Returns:
      Current overflow value. Default value is Canvas.AUTO
      See Also:
    • setSupportsContentsAsPage

      public HTMLPane setSupportsContentsAsPage(boolean supportsContentsAsPage)
      Can this component have its contents specified as a complete standalone HTML page to be rendered into an embedded IFRAME?

      If true, if ContentsType is specified as, or derived to be "page", the contents will be rendered into an embedded IFRAME using the srcdoc attribute rather than written directly into the component handle.

      If false, contentsType has no effect unless contents are being loaded from an explicitly specified contentsURL

      Overrides:
      setSupportsContentsAsPage in class HTMLFlow
      Parameters:
      supportsContentsAsPage - New supportsContentsAsPage value. Default value is true
      Returns:
      HTMLPane instance, for chaining setter calls
    • getSupportsContentsAsPage

      public boolean getSupportsContentsAsPage()
      Can this component have its contents specified as a complete standalone HTML page to be rendered into an embedded IFRAME?

      If true, if ContentsType is specified as, or derived to be "page", the contents will be rendered into an embedded IFRAME using the srcdoc attribute rather than written directly into the component handle.

      If false, contentsType has no effect unless contents are being loaded from an explicitly specified contentsURL

      Overrides:
      getSupportsContentsAsPage in class HTMLFlow
      Returns:
      Current supportsContentsAsPage value. Default value is true
    • setDefaultProperties

      public static void setDefaultProperties(HTMLPane hTMLPaneProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      hTMLPaneProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setIFrameURL

      public void setIFrameURL(String url)
      Sets the contentsURL of this HTMLPane to the supplied url, and the contentsType to ContentsType.PAGE, provided the HTMLPane hasn't been drawn. Throws an AssertionError RuntimeException in GWT Classic DevMode if the HTMLPane has already been drawn.
      Parameters:
      url - the IFrame url
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(HTMLPaneLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class HTMLFlow