Class HtmlControlBlockConditionsHelper


  • public class HtmlControlBlockConditionsHelper
    extends java.lang.Object
    A helper for centralize all block parts rules of HTML Control.
    Since:
    14.0.0
    Version:
    $Revision: 24684 $ $Date: 2021-08-23 18:58:35 -0300 (Mon, 23 Aug 2021) $
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String applyBlocksConditionsOrPutScript​(java.lang.String htmlValue, boolean cacheEnable, java.lang.String websiteUrl, ITransaction transaction)
      If the given cacheEnable parameter is false, the method will remove the HTML block parts that your if, else-if and else conditions are not met.
      static java.lang.String fixForEditorControl​(java.lang.String html)
      Fix value for load in form control.
      static java.lang.String getPrincipalsInfo​(SessionConfig sessionConfig, java.lang.String htmlFieldValue, ITransaction transaction)
      Returns a JSON with principal fields label, value and type mapped by principalId that exists in HTML field value.
      static java.lang.String getPublicHtml​(java.lang.String htmlValue)
      Removes the HTML block parts that are not public.
      static java.lang.String putMetaConfigurationForGetBlocksScript​(java.lang.String htmlValue, java.lang.Object pk, java.lang.String serviceInstanceId, java.lang.String sourceId, java.lang.String fieldId)
      Append in HTML the comment with meta information for client side script that will call a REST for put blocks conditions when exist render cache.
      static void validateBlocks​(java.lang.String fieldId, Source<?> source, java.lang.String html)
      Validate blocks.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HtmlControlBlockConditionsHelper

        public HtmlControlBlockConditionsHelper()
    • Method Detail

      • getPrincipalsInfo

        public static java.lang.String getPrincipalsInfo​(SessionConfig sessionConfig,
                                                         java.lang.String htmlFieldValue,
                                                         ITransaction transaction)
                                                  throws PortalException
        Returns a JSON with principal fields label, value and type mapped by principalId that exists in HTML field value.
        Parameters:
        sessionConfig - the session configuration.
        htmlFieldValue - all HTML of field.
        transaction - the transaction.
        Returns:
        a JSON with principal fields label, value and type mapped by principalId that exists in HTML field value.
        Throws:
        PortalException
        Since:
        14.0.0
      • applyBlocksConditionsOrPutScript

        public static java.lang.String applyBlocksConditionsOrPutScript​(java.lang.String htmlValue,
                                                                        boolean cacheEnable,
                                                                        java.lang.String websiteUrl,
                                                                        ITransaction transaction)
                                                                 throws PortalException
        If the given cacheEnable parameter is false, the method will remove the HTML block parts that your if, else-if and else conditions are not met. Otherwise, the method will replace all conditions blocks with a temporary div and a script that will inject the appropriated HTML blocks.
        Parameters:
        htmlValue - the HTML field value.
        cacheEnable - a flag to inform if the content will be rendered in cache.
        websiteUrl - the website URL.
        transaction - the transaction.
        Returns:
        the HTML with HTML blocks whose conditions are met, or a HTML with script that will fill the conditions block in client side using REST.
        Throws:
        PortalException
        Since:
        14.0.0
      • getPublicHtml

        public static java.lang.String getPublicHtml​(java.lang.String htmlValue)
                                              throws PortalException
        Removes the HTML block parts that are not public.
        Parameters:
        htmlValue - the HTML field value.
        Returns:
        The HTML with only public blocks.
        Throws:
        PortalException
        Since:
        14.1.0
      • putMetaConfigurationForGetBlocksScript

        public static java.lang.String putMetaConfigurationForGetBlocksScript​(java.lang.String htmlValue,
                                                                              java.lang.Object pk,
                                                                              java.lang.String serviceInstanceId,
                                                                              java.lang.String sourceId,
                                                                              java.lang.String fieldId)
                                                                       throws UnexpectedException
        Append in HTML the comment with meta information for client side script that will call a REST for put blocks conditions when exist render cache.
        Parameters:
        htmlValue - the HTML field value.
        pk - the primary key value of register.
        serviceInstanceId - the service instance identifier.
        sourceId - the source identifier.
        fieldId - the field identifier.
        Returns:
        the HTML with comment of meta information for client side script that will call a REST for put blocks conditions when exist render cache.
        Throws:
        UnexpectedException
        Since:
        14.0.0
      • fixForEditorControl

        public static java.lang.String fixForEditorControl​(java.lang.String html)
        Fix value for load in form control.
        Parameters:
        html - the HTML value.
        Returns:
        the HTML fixed.
        Since:
        14.0.0
      • validateBlocks

        public static void validateBlocks​(java.lang.String fieldId,
                                          Source<?> source,
                                          java.lang.String html)
                                   throws PortalException
        Validate blocks.
        Parameters:
        html - all blocks HTML.
        Throws:
        PortalException
        Since:
        14.0.0