Class FromFilePageBuilder

java.lang.Object
org.knime.core.webui.page.PageBuilder
org.knime.core.webui.page.FromFilePageBuilder

public final class FromFilePageBuilder extends PageBuilder
Adds additional methods to the PageBuilder which allows one to define the page content and associated resources by referencing files.
Since:
4.5
Author:
Martin Horn, KNIME GmbH, Konstanz, Germany
  • Method Details

    • addResourceFile

      public FromFilePageBuilder addResourceFile(String relativeFilePath)
      Adds another resource file to the 'context' of a page (such as a js-file). NOTE: the referenced resource-file is expected to be UTF-8-encoded.
      Parameters:
      relativeFilePath - the relative path to the file
      Returns:
      this page builder instance
    • addResourceDirectory

      public FromFilePageBuilder addResourceDirectory(String relativeDirPath)
      Adds all files in the given directory to the 'context' of a page (a directory containing, e.g., js- and css-files). NOTE: the referenced resource-files are expected to be UTF-8-encoded.
      Parameters:
      relativeDirPath - the relative path to the directory
      Returns:
      this page builder instance
    • markAsReusable

      public FromFilePageBuilder markAsReusable(String pageName)
      Marks this page as being re-usable by different nodes (e.g., as node dialog and/or view) and/or port (as port view). A benefit of re-using pages is that the resources associated with the page only need to be requested once for different nodes/ports. Note that page re-use is only possible if the page itself and all associated resources are static (see Resource.isStatic()). And also note that in order for a page to be truly re-used, the very same instance of the page, created with this page builder, must be used by the different nodes/ports.
      Parameters:
      pageName - a name for the re-usable page; must not be null, otherwise it's not marked as re-usable
      Returns:
      this page builder instance
    • build

      public Page build()
      Overrides:
      build in class PageBuilder
      Returns:
      a new page instance
    • addResource

      public FromFilePageBuilder addResource(Supplier<InputStream> content, String relativePath)
      Description copied from class: PageBuilder
      Adds another resource to the 'context' of a page (such js-resource).
      Overrides:
      addResource in class PageBuilder
      Parameters:
      content - the actual content of the resource
      relativePath - the relative path to the resource (including the resource name itself)
      Returns:
      this page builder instance
    • addResourceFromString

      public FromFilePageBuilder addResourceFromString(Supplier<String> content, String relativePath)
      Description copied from class: PageBuilder
      Adds another resource to the 'context' of a page (such js-resource).
      Overrides:
      addResourceFromString in class PageBuilder
      Parameters:
      content - the actual content of the resource
      relativePath - the relative path to the resource (including the resource name itself)
      Returns:
      this page builder instance