Class Content

    • Constructor Detail

      • Content

        public Content​(String idPrefix,
                       IncludeSpec includeSpec)
        Create a new content instance. For every render context this method sets a new uuid with the given prefix. Hyphens in the uuid are eliminated, so the uuid can be used as an javascript identifier.
        Parameters:
        prefix - an optional id prefix
        includeSpec - an optional include spec
    • Method Detail

      • setGlobalIncludeInfo

        public static void setGlobalIncludeInfo​(IncludeInfo info)
        This method configures the html content classes to exclude all content not included by info. With this setting we can speed up document generation without many debug content that is only used in developement situations.
        Parameters:
        info - include info
      • getRenderUuid

        public String getRenderUuid​(RenderContext ctx)
        Returns:
        the uuid for the given context, or null.
      • renderJavascriptOncePerClass

        public static void renderJavascriptOncePerClass​(StringBuilder appender,
                                                        RenderContext ctx)
        This method writes javascript code to appender. Subclasses can also implement an own version of this method. The javascript content will be rendered only once when calling Content#renderHtml(StringBuilder, IncludeInfo, RenderContext, Boolean) with a RenderContext parameter being null.
        Parameters:
        appender -
        ctx -
      • getIncludeSpec

        public IncludeSpec getIncludeSpec()
        Returns:
        the specification object of this content's include behaviour
      • setIncludeSpec

        public void setIncludeSpec​(IncludeSpec spec)
        Parameters:
        new - include spec
      • include

        public boolean include​(IncludeInfo info)
        Parameters:
        info - inclusion info
        Returns:
        true, if this content is to be included
      • getNestedContents

        public abstract Iterable<Content> getNestedContents()
        Returns:
        the set of contents nested in this content. Nested contents can be list items in a List, elements in a Sequence, elements in a Grid, elements in a Paragraph, and so on. If this is a leaf content, the returned set is empty.
      • toString

        public String toString​(String prefix)
        This method is for debugging purposes.
        Parameters:
        prefix - If the output has multiple lines, prefix specifies the indentation of the subsequent lines.
        Returns:
        a string representation of the content and it's internal structure.
      • renderHtml

        public void renderHtml​(StringBuilder appender,
                               IncludeInfo includeInfo,
                               String namespace,
                               boolean useJavascript)
        render content to HTML.
        Parameters:
        appender - HTML code result
        includeInfo - controls, which content to be rendered.
        namespace - the namespace of the rendered HTML. If null, a random namespace string will be generated.
        useJavascript - if true, the generated HTML code will contain Javascript
      • renderHtml

        public void renderHtml​(StringBuilder appender,
                               IncludeInfo includeInfo,
                               RenderContext ctx,
                               boolean useJavascript)
        render content to HTML.
        Parameters:
        appender - HTML code result
        includeInfo - controls, which content to be rendered.
        ctx - render context. If null, a new render context will be instantiated automatically.
        useJavascript - if true, the generated HTML code will contain Javascript
      • renderHtmlImpl

        protected abstract void renderHtmlImpl​(StringBuilder appender,
                                               IncludeInfo includeInfo,
                                               RenderContext ctx,
                                               boolean useJavascript)
        render content to HTML. This method is meant to be overriden by subclasses.
        Parameters:
        appender - HTML code result
        includeInfo - controls, which content to be rendered.
        ctx - render context
        useJavascript - if true, the generated HTML code will contain Javascript
      • renderPlainImpl

        public abstract void renderPlainImpl​(StringBuilder appender,
                                             IncludeInfo includeInfo,
                                             RenderContext ctx)
        render content to plain text. This method is meant to be overriden by subclasses.
        Parameters:
        appender - plain text result
        includeInfo - controls, which content to be rendered.
        ctx - render context (unused).
      • renderPlain

        public void renderPlain​(StringBuilder appender,
                                IncludeInfo includeInfo,
                                String namespace)
        render content to plain text.
        Parameters:
        appender - plain text result
        includeInfo - controls, which content to be rendered.
        namespace - unused
      • renderPlain

        public void renderPlain​(StringBuilder appender,
                                IncludeInfo includeInfo,
                                RenderContext ctx)
        render content to plain text.
        Parameters:
        appender - plain text result
        includeInfo - controls, which content to be rendered.
        ctx - render context (unused).
      • setHref

        public void setHref​(Anchor href)
      • click

        public Action click()
      • hide

        public Action hide()
        Returns:
        an object that can be used to render a javascript snippet that will hide this content and that will render all actions registered with onHide.
      • show

        public Action show()
        Returns:
        an object that can be used to render a javascript snippet that will show this content and that will render all actions registered with onShow.
      • isHidden

        public Condition isHidden()
        Returns:
        an object that can be used to render a javascript snippet that represents a boolean expression being true if this content is currently hidden.
      • isShowing

        public Condition isShowing()
        Returns:
        an object that can be used to render a javascript snippet that represents a boolean expression being true if this content is currently visible.
      • onClick

        public Content onClick​(Action action)
        Register an action that will be rendered in the 'onClick' attribute of this content.
      • onClick

        public Content onClick​(Iterable<Action> actions)
        Register actions that will be rendered in the 'onClick' attribute of this content.
      • onHide

        public Content onHide​(Action action)
        Register an action that will be rendered by hide().
      • onShow

        public Content onShow​(Action action)
        Register an action that will be rendered by show().
      • onLoad

        public Content onLoad​(Action action)
        Register an action that will be rendered at the top level besides this content's HTML markup. This action will be executed when the browser loads the document.
      • onLoad

        public Content onLoad​(Iterable<Action> actions)
        Register actions that will be rendered at the top level besides this content's HTML markup. These actions will be executed when the browser loads the document.
      • registerCallable

        public <T extends ActionCallableAction<T> registerCallable​(T delegate,
                                                                     String functionPrefix)
        Places a javascript snippet besides this content defining a function of the given functionName. The function is implemented by calling the given delegate.
        Parameters:
        delegate -
        functionName -
        Returns:
      • renderOnClickAttribute

        protected void renderOnClickAttribute​(StringBuilder appender,
                                              RenderContext ctx,
                                              boolean useJavascript)
      • enableCallerStacktraceRecording

        public static void enableCallerStacktraceRecording()
        Enables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebase
      • isCallerStacktraceRecordingEnabled

        public static boolean isCallerStacktraceRecordingEnabled()
        Returns:
        true, if stacktrace recording is enabled, which is only the case when regression test behavior recording is enabled
      • disableCallerStacktraceRecording

        public static void disableCallerStacktraceRecording()
        Disables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebase