Class AbstractSectionComponent

Direct Known Subclasses:
MjSection, MjWrapper

public abstract class AbstractSectionComponent extends BodyComponent
Shared base class for <mj-section> and <mj-wrapper>. Extracts identical background-image, box-model, and style-building methods so that each subclass only overrides its specific render logic.
  • Field Details

    • registry

      protected final ComponentRegistry registry
      The component registry used to look up child components during rendering.
  • Constructor Details

    • AbstractSectionComponent

      protected AbstractSectionComponent(MjmlNode node, GlobalContext globalContext, RenderContext renderContext, ComponentRegistry registry)
      Creates a new section component with the given node, context, and registry.
      Parameters:
      node - the MJML node representing this component
      globalContext - the global rendering context
      renderContext - the current render context
      registry - the component registry for resolving child components
  • Method Details

    • getBoxModel

      public CssBoxModel getBoxModel()
      Description copied from class: BodyComponent
      Returns the box model for this component based on its padding and border attributes. The result is cached for repeated access within the same render call.
      Overrides:
      getBoxModel in class BodyComponent
      Returns:
      the CSS box model for this component
    • hasBackgroundUrl

      protected boolean hasBackgroundUrl()
      Checks whether this component has a non-empty background-url attribute.
      Returns:
      true if a background URL is set, false otherwise
    • resolveBackgroundPosition

      protected String resolveBackgroundPosition()
      Resolves background position from individual x/y properties or the combined property. Normalizes "top center" to "center top" format.
      Returns:
      the normalized background position string in "x y" format
    • buildBackgroundCss

      protected String buildBackgroundCss()
      Builds the CSS background shorthand string from this component's background attributes.
      Returns:
      the CSS background shorthand value
    • buildBgImageDivStyle

      protected String buildBgImageDivStyle()
      Builds the inline style string for the outer div when a background image is present.
      Returns:
      the inline CSS style string for the background image div
    • buildBgImageTableStyle

      protected String buildBgImageTableStyle()
      Builds the inline style string for the inner table when a background image is present.
      Returns:
      the inline CSS style string for the background image table
    • getCssClass

      protected String getCssClass()
      Returns the value of the css-class attribute for this component.
      Returns:
      the CSS class string, or an empty string if not set
    • buildInnerTableStyle

      protected String buildInnerTableStyle()
      Builds the inline style string for the inner table element, including background color and optional border-collapse for border-radius support.
      Returns:
      the inline CSS style string for the inner table
    • buildInnerTdStyle

      protected String buildInnerTdStyle()
      Builds the style for the inner td element. Subclasses can override addInnerTdBorderStyles(Map) and addInnerTdExtraStyles(Map) to customize border handling and add extra properties.
      Returns:
      the inline CSS style string for the inner td element
    • addInnerTdBorderStyles

      protected void addInnerTdBorderStyles(Map<String,String> styles)
      Adds border styles to the inner td style map. Default implementation adds only the "border" attribute if non-empty and not "none". Subclasses can override to use the full addBorderStyles() helper.
      Parameters:
      styles - the mutable style map to add border properties to
    • addInnerTdExtraStyles

      protected void addInnerTdExtraStyles(Map<String,String> styles)
      Adds extra styles between border-radius and font-size. Default is no-op.
      Parameters:
      styles - the mutable style map to add extra properties to
    • addInnerTdPaddingOverrides

      protected void addInnerTdPaddingOverrides(Map<String,String> styles)
      Adds individual padding overrides. Default is no-op.
      Parameters:
      styles - the mutable style map to add padding overrides to
    • renderNormalScaffold

      protected String renderNormalScaffold(String vmlRect, String innerContent, String outerDivClass)
      Renders the normal (non-full-width) scaffold shared by mj-section and mj-wrapper. Both components follow the same MSO table → VML rect → div/table → inner content → close structure; subclasses provide the VML rect string, inner content, and optional css-class on the outer div.
      Parameters:
      vmlRect - VML rect markup for background images (from VmlHelper)
      innerContent - rendered inner content (columns for section, wrapped children for wrapper)
      outerDivClass - optional CSS class to add to the outer div (empty string if none)
      Returns:
      the rendered HTML scaffold string
    • buildOuterDivStyle

      protected String buildOuterDivStyle()
      Builds the outer div style with background color, max-width, and optional border-radius. Used by both mj-section (as buildSectionStyle) and mj-wrapper (as buildWrapperStyle).
      Returns:
      the inline CSS style string for the outer div