| java.lang.Object com.salmonllc.html.HtmlComponentValidator
HtmlComponentValidator | public class HtmlComponentValidator (Code) | | This class can be used to do basic validations against rows and columns in a DataStore. Simple Validation Rules can be added using the addValidationRule method and all the tests can be iterated through using the findFirstError and findNextError methods.
|
Method Summary | |
public void | addExpressionRule(String expression, String errorMessage, HtmlFormComponent focusComp) Use this method to add validation rules that will be checked by the validator. | public void | addExpressionRule(DataStoreExpression expression, String errorMessage, HtmlFormComponent focusComp) Use this method to add validation rules that will be checked by the validator.
Parameters: expression - A DataStoreExpression class that returns a boolean value. | void | addJavaScriptRule(String javaScript, String errorMessage, HtmlFormComponent focusComp) | public void | addLookupRule(String lookupTable, String searchExpression, String errorMessage, HtmlFormComponent focusComp) Use this method to add validation rules that will be checked via a lookup to another table. | public void | addLookupRule(String lookupTable, String searchExpression, String errorMessage, HtmlFormComponent focusComp, String descColumn, String descBucket) Use this method to add validation rules that will be checked via a lookup to another table. | public void | addLookupRule(String lookupTable, DataStoreExpression searchExpression, String errorMessage, HtmlFormComponent focusComp) Use this method to add validation rules that will be checked via a lookup to another table. | public void | addLookupRule(String lookupTable, DataStoreExpression searchExpression, String errorMessage, HtmlFormComponent focusComp, String descColumn, String descBucket) Use this method to add validation rules that will be checked via a lookup to another table. | public void | addRangeRule(String column, Object minValue, Object maxValue, String errorMessage, HtmlFormComponent focusComp) Use this method to add a range validation rule that will be checked by the validator. | public void | addRegularExpressionRule(String column, String regExp, String errorMessage, HtmlFormComponent focusComp) Adds a regular expression rule to the datastore. | public void | addRequiredRule(String column, String errorMessage, HtmlFormComponent focusComp) Use this method to add validation rules that will be checked for a required field. | public boolean | findNextError() Use this method to find the next rule that is being violated using the current row in the DataStore. | public boolean | findNextError(int rowNo) Use this method to find the next rule that is being violated.
Parameters: rowNo - The row number in the DataStore to validate. | public int | getCurrentRule() | public DataStoreBuffer | getDataStoreBuffer() This method returns the DataStoreBuffer that the component will validate. | public HtmlFormComponent | getErrorComponent() This method returns the HtmlComponent that should have the focus when it's corresponding rule is violated or null if there are no errors. | public String | getErrorMessage() This method returns the error message that should be displayed when the current rule is violated or null if there are no errors. | public int | getRuleCount() | public String | getRuleErrorMessage(int ruleNo) | public HtmlFormComponent | getRuleFocusComponent(int ruleNo) | String | getRuleJavaScript(int ruleNo) | Object | getRuleMaxValue(int ruleNo) | Object | getRuleMinValue(int ruleNo) | RegularExpressionMatcher | getRuleRegExpression(int ruleNo) | public int | getRuleType(int ruleNo) | public boolean | getValidateExpression() | public boolean | getValidateLookup() | public boolean | getValidateRange() | public boolean | getValidateRegExp() | public boolean | getValidateRequired() | public void | populateDescriptions() Use this method to fill in the descriptions for lookup columns for the current row in the datastore. | public void | populateDescriptions(int rowNo) Use this method to fill in the descriptions for lookup columns. | public void | reset() Use this method to reset the validator to the first rule in the list. | public void | setValidateExpression(boolean b) | public void | setValidateLookup(boolean b) | public void | setValidateRange(boolean b) | public void | setValidateRegExp(boolean b) | public void | setValidateRequired(boolean b) |
HtmlComponentValidator | public HtmlComponentValidator(String applicationName, DataStoreBuffer ds)(Code) | | Constructs a new HtmlComponentValidator based on the DataStoreBuffer passed in.
|
HtmlComponentValidator | public HtmlComponentValidator(String applicationName, String DBProfile, DataStoreBuffer ds)(Code) | | Constructs a new HtmlComponentValidator based on the DataStoreBuffer passed in.
|
addExpressionRule | public void addExpressionRule(String expression, String errorMessage, HtmlFormComponent focusComp) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked by the validator.
Parameters: expression - A boolean expression that will trigger an error if evaluated to false. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus too if the error expression returns false. |
addExpressionRule | public void addExpressionRule(DataStoreExpression expression, String errorMessage, HtmlFormComponent focusComp) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked by the validator.
Parameters: expression - A DataStoreExpression class that returns a boolean value. It will trigger an error if the value returns false. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus too if the error expression returns false. |
addLookupRule | public void addLookupRule(String lookupTable, String searchExpression, String errorMessage, HtmlFormComponent focusComp) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked via a lookup to another table.
Parameters: lookupTable - The name of the table to lookup the value against. Parameters: searchExpression - A DataStoreEvaluator expression that returns a String and will be used as the where clause for the SQL that will validate the data. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus to if the error expression returns false. |
addLookupRule | public void addLookupRule(String lookupTable, String searchExpression, String errorMessage, HtmlFormComponent focusComp, String descColumn, String descBucket) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked via a lookup to another table. In addition to checking if a set of columns are valid, this type of rule will also fill in a bucket in the datastore with a description taken from the row retrieved in the lookup table.
Parameters: lookupTable - The name of the table to lookup the value against. Parameters: searchExpression - A DataStoreEvaluator expression that returns a String and will be used as the where clause for the SQL that will validate the data. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus to if the error expression returns false. Parameters: descColumn - The name of the column in the lookup table used to fill in the description. Parameters: descBucket - The name of a bucket column in the datastore to place the description. |
addLookupRule | public void addLookupRule(String lookupTable, DataStoreExpression searchExpression, String errorMessage, HtmlFormComponent focusComp) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked via a lookup to another table.
Parameters: lookupTable - The name of the table to lookup the value against. Parameters: searchExpression - A DataStoreExpression that returns a String and will be used as the where clause for the SQL that will validate the data. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus to if the error expression returns false. |
addLookupRule | public void addLookupRule(String lookupTable, DataStoreExpression searchExpression, String errorMessage, HtmlFormComponent focusComp, String descColumn, String descBucket) throws DataStoreException(Code) | | Use this method to add validation rules that will be checked via a lookup to another table. In addition to checking if a set of columns are valid, this type of rule will also fill in a bucket in the datastore with a description taken from the row retrieved in the lookup table.
Parameters: lookupTable - The name of the table to lookup the value against. Parameters: searchExpression - A DataStoreExpression that returns a String and will be used as the where clause for the SQL that will validate the data. Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus to if the error expression returns false. Parameters: descColumn - The name of the column in the lookup table used to fill in the description. Parameters: descBucket - The name of a bucket column in the datastore to place the description. |
addRangeRule | public void addRangeRule(String column, Object minValue, Object maxValue, String errorMessage, HtmlFormComponent focusComp) throws DataStoreException(Code) | | Use this method to add a range validation rule that will be checked by the validator.
Parameters: minValue - The minimum allowed value in the component Parameters: maxValue - The maximum allowed value in the component Parameters: errorMessage - The error message to display if the error expression returns false. Parameters: focusComp - The HtmlComponent to set focus too if the error expression returns false. |
addRegularExpressionRule | public void addRegularExpressionRule(String column, String regExp, String errorMessage, HtmlFormComponent focusComp)(Code) | | Adds a regular expression rule to the datastore. The rule will be violated if the value in the focus component doesn't match the regular expression
Parameters: The - column to validate Parameters: regExp - The regular expression to use for validation Parameters: errorMessage - The error message to display if the field is not filled in. Parameters: focusComp - The HtmlComponent to set focus too if the error expression returns false. |
addRequiredRule | public void addRequiredRule(String column, String errorMessage, HtmlFormComponent focusComp)(Code) | | Use this method to add validation rules that will be checked for a required field.
Parameters: column - The colum to validate Parameters: errorMessage - The error message to display if the field is not filled in. Parameters: focusComp - The HtmlComponent to set focus too if the error expression returns false. |
findNextError | public boolean findNextError() throws Exception(Code) | | Use this method to find the next rule that is being violated using the current row in the DataStore.
true if no errors are found and false if an error is found. |
findNextError | public boolean findNextError(int rowNo) throws Exception(Code) | | Use this method to find the next rule that is being violated.
Parameters: rowNo - The row number in the DataStore to validate. true if no errors are found and false if an error is found. |
getCurrentRule | public int getCurrentRule()(Code) | | Returns the number of the rule that was violated or -1 if none was
|
getDataStoreBuffer | public DataStoreBuffer getDataStoreBuffer()(Code) | | This method returns the DataStoreBuffer that the component will validate.
|
getErrorComponent | public HtmlFormComponent getErrorComponent()(Code) | | This method returns the HtmlComponent that should have the focus when it's corresponding rule is violated or null if there are no errors.
|
getErrorMessage | public String getErrorMessage()(Code) | | This method returns the error message that should be displayed when the current rule is violated or null if there are no errors.
|
getRuleCount | public int getRuleCount()(Code) | | Return the number of rules in the validator
|
getRuleErrorMessage | public String getRuleErrorMessage(int ruleNo)(Code) | | Returns the error message associated with a rule
|
getRuleFocusComponent | public HtmlFormComponent getRuleFocusComponent(int ruleNo)(Code) | | Returns the form component associated with a rule
|
getRuleJavaScript | String getRuleJavaScript(int ruleNo)(Code) | | |
getRuleType | public int getRuleType(int ruleNo)(Code) | | Returns the type of validation rule (com.salmonllc.sql.ValidationRule TYPE_ constants)
|
getValidateExpression | public boolean getValidateExpression()(Code) | | |
getValidateLookup | public boolean getValidateLookup()(Code) | | |
getValidateRange | public boolean getValidateRange()(Code) | | |
getValidateRegExp | public boolean getValidateRegExp()(Code) | | |
getValidateRequired | public boolean getValidateRequired()(Code) | | |
populateDescriptions | public void populateDescriptions() throws Exception(Code) | | Use this method to fill in the descriptions for lookup columns for the current row in the datastore.
|
populateDescriptions | public void populateDescriptions(int rowNo) throws Exception(Code) | | Use this method to fill in the descriptions for lookup columns.
Parameters: rowNo - The row number in the DataStore to fill in. |
reset | public void reset()(Code) | | Use this method to reset the validator to the first rule in the list. Subsequent calls to findNextError will begin checking with the first rule instead of the one with the last error.
|
setValidateExpression | public void setValidateExpression(boolean b)(Code) | | Parameters: b - |
setValidateLookup | public void setValidateLookup(boolean b)(Code) | | Parameters: b - |
setValidateRange | public void setValidateRange(boolean b)(Code) | | Parameters: b - |
setValidateRegExp | public void setValidateRegExp(boolean b)(Code) | | Parameters: b - |
setValidateRequired | public void setValidateRequired(boolean b)(Code) | | Parameters: b - |
|
|