Class HtmlControlBlockConditionsHelper


  • public class HtmlControlBlockConditionsHelper
    extends Object
    A helper for centralize all block parts rules of HTML Control.
    Since:
    14.0.0
    Version:
    $Revision: 24476 $ $Date: 2021-04-28 11:28:23 -0300 (Wed, 28 Apr 2021) $
    • Constructor Detail

      • HtmlControlBlockConditionsHelper

        public HtmlControlBlockConditionsHelper()
    • Method Detail

      • getPrincipalsInfo

        public static String getPrincipalsInfo​(SessionConfig sessionConfig,
                                               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 String applyBlocksConditionsOrPutScript​(String htmlValue,
                                                              boolean cacheEnable,
                                                              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
      • putMetaConfigurationForGetBlocksScript

        public static String putMetaConfigurationForGetBlocksScript​(String htmlValue,
                                                                    Object pk,
                                                                    String serviceInstanceId,
                                                                    String sourceId,
                                                                    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 String fixForEditorControl​(String html)
        Fix value for load in form control.
        Parameters:
        html - the HTML value.
        Returns:
        the HTML fixed.
        Since:
        14.0.0