Package com.day.cq.wcm.foundation.forms
Class LayoutHelper
- java.lang.Object
-
- com.day.cq.wcm.foundation.forms.LayoutHelper
-
public class LayoutHelper extends java.lang.ObjectHelper class for the forms components for layouting.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidprintDescription(java.lang.String descr, java.io.Writer out)Print the description Thedescriptionis encoded usingStringEscapeUtils.escapeHtml4(String)before it is written to theWriter.static voidprintDescription(java.lang.String fieldId, java.lang.String descr, java.io.Writer out)Print the description IffieldIdis set the description will be enclosed in a label for accessibility.static voidprintErrors(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 booleanprintErrors(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 voidprintErrors(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 booleanprintErrors(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 voidprintTitle(java.lang.String fieldId, java.lang.String title, boolean required, boolean hideLabel, java.io.Writer out)Print the left column, title and required.static voidprintTitle(java.lang.String fieldId, java.lang.String title, boolean required, java.io.Writer out)Print the left column, title and required.
-
-
-
Method Detail
-
printTitle
public static void printTitle(java.lang.String fieldId, java.lang.String title, boolean required, java.io.Writer out) throws java.io.IOExceptionPrint 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. Thetitleis encoded usingStringEscapeUtils.escapeHtml4(String)before it is written to theWriter.- 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.IOExceptionPrint 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. Thetitleis encoded usingStringEscapeUtils.escapeHtml4(String)before it is written to theWriter.- 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.IOExceptionPrint the description Thedescriptionis encoded usingStringEscapeUtils.escapeHtml4(String)before it is written to theWriter.- 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.IOExceptionPrint the description IffieldIdis 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. Thedescriptionis encoded usingStringEscapeUtils.escapeHtml4(String)before it is written to theWriter.- 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, thenprintTitle(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, thenprintTitle(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
trueif 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, thenprintTitle(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, thenprintTitle(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
trueif an error has been printed (since 5.5) - Throws:
java.io.IOException- If writing fails.- Since:
- 5.4
-
-