Class LayoutHelper


  • public class LayoutHelper
    extends Object
    Helper class for the forms components for layouting.
    • Method Detail

      • printTitle

        public static void printTitle​(String fieldId,
                                      String title,
                                      boolean required,
                                      Writer out)
                               throws IOException
        Print the left column, title and required. This method creates a wrapper div with the class form_leftcol, inside the divs are two divs, the first one containing the label with the class form_leftcollabel. The second inner div contains a star if the field is required, the div has the class form_leftcolmark. The title is encoded using StringEscapeUtils.escapeHtml4(String) before it is written to the Writer.
        Parameters:
        fieldId - The id of the field (not the name) - This can be null if title is null.
        title - The title of the field (or null)
        required - Flag indicating if this field is required.
        out - The writer.
        Throws:
        IOException - If writing fails.
      • printTitle

        public static void printTitle​(String fieldId,
                                      String title,
                                      boolean required,
                                      boolean hideLabel,
                                      Writer out)
                               throws IOException
        Print the left column, title and required. This method creates a wrapper div with the class form_leftcol, inside the divs are two divs, the first one containing the label with the class form_leftcollabel. The second inner div contains a star if the field is required, the div has the class form_leftcolmark. The title is encoded using StringEscapeUtils.escapeHtml4(String) before it is written to the Writer.
        Parameters:
        fieldId - The id of the field (not the name) - This can be null if title is null.
        title - The title of the field (or null)
        required - Flag indicating if this field is required.
        hideLabel - Option to completely hide the label (removes form_leftcollabel and form_leftcolmark divs content)
        out - The writer.
        Throws:
        IOException - If writing fails.
        Since:
        5.4
      • printDescription

        public static void printDescription​(String fieldId,
                                            String descr,
                                            Writer out)
                                     throws IOException
        Print the description If fieldId is set the description will be enclosed in a label for accessibility. This facility should only be used when the field has no title, or the title is not used as a label for some reason. The description is encoded using StringEscapeUtils.escapeHtml4(String) before it is written to the Writer.
        Parameters:
        fieldId - Field id.
        descr - The description of the field (or null)
        out - The writer.
        Throws:
        IOException - If writing fails.
      • printErrors

        public static void printErrors​(SlingHttpServletRequest request,
                                       String fieldName,
                                       Writer out)
                                throws IOException
        Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created. The div has the class form_row, then printTitle(String, String, boolean, Writer) is called and a third inner div with the message and the classes form_rightcol and form_error is created.
        Parameters:
        request - The current request.
        fieldName - The name of the field (not the id!)
        out - The writer.
        Throws:
        IOException - If writing fails.
      • printErrors

        public static boolean printErrors​(SlingHttpServletRequest request,
                                          String fieldName,
                                          Writer out,
                                          int valueIndex)
                                   throws IOException
        Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created. The div has the class form_row, then printTitle(String, String, boolean, Writer) is called and a third inner div with the message and the classes form_rightcol and form_error is created.
        Parameters:
        request - The current request.
        fieldName - The name of the field (not the id!)
        out - The writer.
        valueIndex - value index
        Returns:
        Returns true if an error has been printed (since 5.5)
        Throws:
        IOException - If writing fails.
        Since:
        5.3
      • printErrors

        public static void printErrors​(SlingHttpServletRequest request,
                                       String fieldName,
                                       boolean hideLabel,
                                       Writer out)
                                throws IOException
        Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created. The div has the class form_row, then printTitle(String, String, boolean, Writer) is called and a third inner div with the message and the classes form_rightcol and form_error is created.
        Parameters:
        request - The current request.
        fieldName - The name of the field (not the id!)
        hideLabel - Option to completely hide the label (removes form_leftcollabel and form_leftcolmark divs content)
        out - The writer.
        Throws:
        IOException - If writing fails.
        Since:
        5.4
      • printErrors

        public static boolean printErrors​(SlingHttpServletRequest request,
                                          String fieldName,
                                          boolean hideLabel,
                                          Writer out,
                                          int valueIndex)
                                   throws IOException
        Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created. The div has the class form_row, then printTitle(String, String, boolean, Writer) is called and a third inner div with the message and the classes form_rightcol and form_error is created.
        Parameters:
        request - The current request.
        fieldName - The name of the field (not the id!)
        hideLabel - Option to completely hide the label (removes form_leftcollabel and form_leftcolmark divs content)
        out - The writer.
        valueIndex - value index
        Returns:
        Returns true if an error has been printed (since 5.5)
        Throws:
        IOException - If writing fails.
        Since:
        5.4