String[] values = context.getRequest().getParameterValues(propertyName); log.debug("Checking required field: ", propertyName, ", with values: ", values); checkSingleRequiredField(propertyName, propertyName, values, errors);
if (!wizard || fieldsOnPage.contains(propertyName)) { String[] values = bean.getContext().getRequest().getParameterValues(propertyName); log.debug("Checking required field: ", propertyName, ", with values: ", values); checkSingleRequiredField(propertyName, propertyName, values, errors); }
    protected void validateRequiredFields(Map<ParameterName,String[]> parameters,                                          ActionBeanContext context,                                          Class beanClass,                                          ValidationErrors errors) {        log.debug("Running required field validation on bean class ", beanClass.getName());        // Assemble a set of names that we know have indexed parameters, so we won't check        // for required-ness the regular way        Set<String> indexedParams = new HashSet<String>();        for (ParameterName name : parameters.keySet()) {            if (name.isIndexed()) {                indexedParams.add(name.getStrippedName());            }        }        Map<String,Validate> validationInfos = this.validations.get(beanClass);        if (validationInfos != null) {            for (Map.Entry<String,Validate> entry : validationInfos.entrySet()) {                String propertyName = entry.getKey();                Validate 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.required() && !indexedParams.contains(propertyName)) {                    String[] values = context.getRequest().getParameterValues(propertyName);                    log.debug("Checking required field: ", propertyName, ", with values: ", values);                    checkSingleRequiredField(propertyName, propertyName, values, 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();                        Validate validationInfo = validationInfos.get(name.getStrippedName());                        if (validationInfo != null && validationInfo.required()) {                            checkSingleRequiredField                                    (name.getName(), name.getStrippedName(), values, errors);                        }                    }                }                else {                    // If the row is full of empty data, get rid of it all to                    // prevent problems in downstream validation                    for (ParameterName name : row.keySet()) {                        parameters.remove(name);                    }                }            }        }    }