|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.core.forms.FormUtil
Simple Form related utilities
Field Summary | |
protected static org.apache.log4j.Logger |
logger
|
Constructor Summary | |
FormUtil()
|
Method Summary | |
static String |
assertMinMax(String field,
String fieldDescr,
int min,
int max)
This method allows you to assert that a String value falls within a given min/max length range. |
static void |
assertTrue(String errmsg,
boolean expression)
This function simply evaluates a given boolean expression and throws a ValidationException using the specified error message if its not valid |
static void |
flagErrors(BComponent bcomp)
Convenience method to have the ErrorManager flag a component for errors (if they exist). |
static String |
formatForOutput(Object val,
FormElement el)
Convenience method to format form values in a friendly manner (based on their data type) that will allow for later reparsing |
static void |
repopulate(FormMap fm,
BComponent bcomp)
Given a BComponent and a reference to a FormMap, this method will automatically repopulate the form value into the component. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final org.apache.log4j.Logger logger
Constructor Detail |
public FormUtil()
Method Detail |
public static void repopulate(FormMap fm, BComponent bcomp)
fm
- the backing form mapbcomp
- the component to be repopulatedpublic static String formatForOutput(Object val, FormElement el)
public static void flagErrors(BComponent bcomp)
bcomp
- the component to be flaggedErrorManager.apply(BComponent)
public static String assertMinMax(String field, String fieldDescr, int min, int max) throws ValidationException
This method allows you to assert that a String value falls within a given min/max length range. If min or max is -1, that particular aspect will not be evaluated.
Example usage:
String user = assertMinMax((String) map.get(USER), "User Name", 5, 30);
This would retrieve a username from a map, validate it to ensure that its between 5 and 30 characters in length, and then return the adjusted value (if it was null in the map, it will come back as "", which is convenient for further custom evaluation)
Todo:
field
- the field to be evaluatedfieldDescr
- a description of the field to be included in any error messagesmin
- the minimum length of the String, or -1 if there is no minmax
- the maximum length of the String, or -1 if there is no max
a
- ValidationException if the field is not valid
ValidationException
public static void assertTrue(String errmsg, boolean expression) throws ValidationException
errmsg
- the error message to be used if the expression is invalidexpression
- the expression to be evaluated
ValidationException
- if the expression is not true
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |