Class CmsElementUtil


  • public class CmsElementUtil
    extends java.lang.Object
    Utility class to generate the element data objects used within the container-page editor.

    Since:
    8.0.0
    • Constructor Detail

      • CmsElementUtil

        public CmsElementUtil​(CmsObject cms,
                              java.lang.String currentPageUri,
                              CmsContainerPageBean containerPage,
                              CmsUUID detailContentId,
                              javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse res,
                              boolean isDragMode,
                              java.util.Locale locale)
                       throws CmsException
        Creates a new instance.

        Use this constructor to set the current container page state.

        Parameters:
        cms - the cms context
        currentPageUri - the current page uri
        containerPage - the container page bean with the current container state
        detailContentId - the detail content structure id
        req - the http request
        res - the http response
        isDragMode - if the page is in drag mode
        locale - the content locale
        Throws:
        CmsException - if something goes wrong
      • CmsElementUtil

        public CmsElementUtil​(CmsObject cms,
                              java.lang.String currentPageUri,
                              CmsUUID detailContentId,
                              javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse res,
                              java.util.Locale locale)
                       throws CmsException
        Creates a new instance.

        Parameters:
        cms - the cms context
        currentPageUri - the current page uri
        detailContentId - the detail content structure id
        req - the http request
        res - the http response
        locale - the content locale
        Throws:
        CmsException - if something goes wrong
      • CmsElementUtil

        public CmsElementUtil​(CmsObject cms,
                              java.lang.String currentPageUri,
                              CmsUUID detailContentId,
                              java.lang.String requestParameters,
                              javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse res,
                              java.util.Locale locale)
                       throws CmsException
        Creates a new instance.

        Parameters:
        cms - the cms context
        currentPageUri - the current page uri
        detailContentId - the detail content structure id
        requestParameters - the request parameters to use while rendering the elements
        req - the http request
        res - the http response
        locale - the content locale
        Throws:
        CmsException - if something goes wrong
    • Method Detail

      • checkGroupAllowed

        public static boolean checkGroupAllowed​(java.lang.String containerType,
                                                CmsGroupContainerBean groupContainer)
        Checks if a group element is allowed in a container with a given type.

        Parameters:
        containerType - the container type spec (comma separated)
        groupContainer - the group
        Returns:
        true if the group is allowed in the container
      • createStringTemplateSource

        public static java.util.function.Function<java.lang.String,​java.lang.String> createStringTemplateSource​(I_CmsFormatterBean formatter,
                                                                                                                      com.google.common.base.Supplier<CmsXmlContent> contentSupplier)
        Helper method to create a string template source for a given formatter and content.
        Parameters:
        formatter - the formatter
        contentSupplier - the content supplier
        Returns:
        the string template provider
      • getContentByContainer

        public java.lang.String getContentByContainer​(CmsFile elementFile,
                                                      java.lang.String elementId,
                                                      CmsContainer container)
        Returns the HTML content for the given resource and container.

        Parameters:
        elementFile - the element resource file
        elementId - the element id
        container - the container
        Returns:
        the HTML content
      • getPage

        public CmsResource getPage()
        Gets the container page.

        Returns:
        the container page resource