use of org.alfresco.repo.dictionary.constraint.StringLengthConstraint in project acs-community-packaging by Alfresco.
the class BaseComponentGenerator method setupStringLengthConstraint.
/**
* Sets up a default validation rule for the string length constraint
*
* @param context FacesContext
* @param propertySheet The property sheet to add the validation rule to
* @param property The property being generated
* @param component The component representing the property
* @param constraint The constraint to setup
* @param realTimeChecking true to make the client validate as the user types
*/
protected void setupStringLengthConstraint(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, UIComponent component, StringLengthConstraint constraint, boolean realTimeChecking) {
int min = constraint.getMinLength();
int max = constraint.getMaxLength();
List<String> params = new ArrayList<String>(3);
// add the value parameter
String value = "document.getElementById('" + component.getClientId(context) + "')";
params.add(value);
// add the min parameter
params.add(Integer.toString(min));
// add the max parameter
params.add(Integer.toString(max));
// add the validation failed message to show
String msg = Application.getMessage(context, "validation_string_length");
addStringConstraintParam(params, MessageFormat.format(msg, new Object[] { property.getResolvedDisplayLabel(), min, max }));
// add the validation case to the property sheet
propertySheet.addClientValidation(new ClientValidation("validateStringLength", params, realTimeChecking));
}
Aggregations