Class LayoutHelper


  • public class LayoutHelper
    extends java.lang.Object
    Helper class for the forms components for layouting.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void printDescription​(java.lang.String descr, java.io.Writer out)
      Print the description The description is encoded using StringEscapeUtils.escapeHtml4(String) before it is written to the Writer.
      static void printDescription​(java.lang.String fieldId, java.lang.String descr, java.io.Writer out)
      Print the description If fieldId is set the description will be enclosed in a label for accessibility.
      static void printErrors​(SlingHttpServletRequest request, java.lang.String fieldName, boolean hideLabel, java.io.Writer out)
      Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created.
      static boolean printErrors​(SlingHttpServletRequest request, java.lang.String fieldName, boolean hideLabel, java.io.Writer out, int valueIndex)
      Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created.
      static void printErrors​(SlingHttpServletRequest request, java.lang.String fieldName, java.io.Writer out)
      Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created.
      static boolean printErrors​(SlingHttpServletRequest request, java.lang.String fieldName, java.io.Writer out, int valueIndex)
      Print all errors (if there are any.) If there are error messages for this field, a div for each error message is created.
      static void printTitle​(java.lang.String fieldId, java.lang.String title, boolean required, boolean hideLabel, java.io.Writer out)
      Print the left column, title and required.
      static void printTitle​(java.lang.String fieldId, java.lang.String title, boolean required, java.io.Writer out)
      Print the left column, title and required.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • printTitle

        public static void printTitle​(java.lang.String fieldId,
                                      java.lang.String title,
                                      boolean required,
                                      java.io.Writer out)
                               throws java.io.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:
        java.io.IOException - If writing fails.
      • printTitle

        public static void printTitle​(java.lang.String fieldId,
                                      java.lang.String title,
                                      boolean required,
                                      boolean hideLabel,
                                      java.io.Writer out)
                               throws java.io.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:
        java.io.IOException - If writing fails.
        Since:
        5.4
      • printDescription

        public static void printDescription​(java.lang.String descr,
                                            java.io.Writer out)
                                     throws java.io.IOException
        Print the description The description is encoded using StringEscapeUtils.escapeHtml4(String) before it is written to the Writer.
        Parameters:
        descr - The description of the field (or null)
        out - The writer.
        Throws:
        java.io.IOException - If writing fails.
      • printDescription

        public static void printDescription​(java.lang.String fieldId,
                                            java.lang.String descr,
                                            java.io.Writer out)
                                     throws java.io.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:
        java.io.IOException - If writing fails.
      • printErrors

        public static void printErrors​(SlingHttpServletRequest request,
                                       java.lang.String fieldName,
                                       java.io.Writer out)
                                throws java.io.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:
        java.io.IOException - If writing fails.
      • printErrors

        public static boolean printErrors​(SlingHttpServletRequest request,
                                          java.lang.String fieldName,
                                          java.io.Writer out,
                                          int valueIndex)
                                   throws java.io.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:
        java.io.IOException - If writing fails.
        Since:
        5.3
      • printErrors

        public static void printErrors​(SlingHttpServletRequest request,
                                       java.lang.String fieldName,
                                       boolean hideLabel,
                                       java.io.Writer out)
                                throws java.io.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:
        java.io.IOException - If writing fails.
        Since:
        5.4
      • printErrors

        public static boolean printErrors​(SlingHttpServletRequest request,
                                          java.lang.String fieldName,
                                          boolean hideLabel,
                                          java.io.Writer out,
                                          int valueIndex)
                                   throws java.io.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:
        java.io.IOException - If writing fails.
        Since:
        5.4