boolean wizard = bean.getClass().getAnnotation(Wizard.class) != null;
Collection<String> fieldsOnPage = getFieldsPresentInfo(bean);
for (Map.Entry<String, ValidationMetadata> entry : validationInfos.entrySet()) {
String propertyName = entry.getKey();
ValidationMetadata validationInfo = entry.getValue();
// If the field is required, and we don't have index params that collapse
// to that property name, check that it was supplied
if (validationInfo.requiredOn(context.getEventName())
&& !indexedParams.contains(propertyName)) {
// Make the added check that if the form is a wizard, the required field is
// in the set of fields that were on the page
if (!wizard || fieldsOnPage.contains(propertyName)) {
String[] values = trim(request.getParameterValues(propertyName), validationInfo);
// Decrypt encrypted fields before checking for null
if (validationInfo.encrypted()) {
for (int i = 0, n = values.length; i < n; i++) {
if (values[i] != null)
values[i] = CryptoUtil.decrypt(values[i]);
}
}
log.debug("Checking required field: ", propertyName, ", with values: ", values);
checkSingleRequiredField(propertyName, propertyName, values, stripesReq, errors);
}
}
}
}
// Now the easy work is done, figure out which rows of indexed props had values submitted
// and what to flag up as failing required field validation
if (indexedParams.size() > 0) {
Map<String, Row> rows = new HashMap<String, Row>();
for (Map.Entry<ParameterName, String[]> entry : parameters.entrySet()) {
ParameterName name = entry.getKey();
String[] values = entry.getValue();
if (name.isIndexed()) {
String rowKey = name.getName().substring(0, name.getName().indexOf(']') + 1);
if (!rows.containsKey(rowKey)) {
rows.put(rowKey, new Row());
}
rows.get(rowKey).put(name, values);
}
}
for (Row row : rows.values()) {
if (row.hasNonEmptyValues()) {
for (Map.Entry<ParameterName, String[]> entry : row.entrySet()) {
ParameterName name = entry.getKey();
String[] values = entry.getValue();
ValidationMetadata validationInfo = validationInfos.get(name.getStrippedName());
if (validationInfo != null
&& validationInfo.requiredOn(context.getEventName())) {
checkSingleRequiredField(name.getName(), name.getStrippedName(),
values, stripesReq, errors);
}
}
}