List of usage examples for org.apache.commons.validator Field setIndexedListProperty
public void setIndexedListProperty(String indexedListProperty)
From source file:jp.terasoluna.fw.web.struts.form.FieldChecksEx.java
/** * z?ERNV^tB?[hlSvf`FbN?B/*from w w w.jav a 2s . c o m*/ * <p> * z?ERNV^tH?[vf??A? CfbNX? <code>ActionMessage</code>?B * ?sTu?\bh?^?A???A?\bh vKv?B * Fieldproperty?JXPathIndexedBeanWrapperImpldl?]?A * lXgv?peB?\?B * </p> * * @param bean * ??IuWFNg * @param va * Strutsp<code>ValidatorAction</code> * @param field * tB?[hIuWFNg * @param errors * ANVG?[ * @param validator * ValidatorCX^X * @param request * HTTPNGXg * @return vfl? <code>true</code> */ public static boolean validateArraysIndex(@SuppressWarnings("unused") Object bean, ValidatorAction va, Field field, ActionMessages errors, Validator validator, HttpServletRequest request) { // ?? int methodArgCount = 6; // z?ERNV???ifalsep???Afalse?j boolean totalResult = true; try { // RXgN^?NXp^?[ Class[] paramClass = getParamClass(va); if (paramClass == null) { log.error("Can not get class pattern."); return true; } // paramClassvf?=0?AG?[?O?o?Atruep if (paramClass.length == 0) { log.error("Class pattern length is zero."); return true; } // evf??s?\bh Method method = getMethod(va, paramClass); if (method == null) { log.error("Can not get validateMethod."); return true; } // tH?[IuWFNg ActionForm form = getActionForm(request); if (form == null) { log.error("Can not get ActionForm."); return true; } // vfof?[V?[?A // O?svIuWFNg Object[] argParams = new Object[methodArgCount]; argParams[0] = form; argParams[1] = va; argParams[3] = errors; argParams[4] = validator; argParams[5] = request; IndexedBeanWrapper wrapper = new JXPathIndexedBeanWrapperImpl(form); Map<String, Object> propertyMap = wrapper.getIndexedPropertyValues(field.getKey()); int index = 0; for (String key : propertyMap.keySet()) { // CfbNXtv?peBtB?[h? Field indexedField = (Field) field.clone(); indexedField.setIndexedListProperty(null); indexedField = getArrayIndexField(indexedField, index); indexedField.setKey(key); indexedField.setProperty(key); argParams[2] = indexedField; // tB?[h // `FbN?\bh?o Object resultObj = method.invoke(FieldChecksEx.class, argParams); // ? if (!isValid(resultObj)) { totalResult = false; } index++; } } catch (IllegalArgumentException e) { log.error("", e); return true; } catch (IllegalAccessException e) { log.error("", e); return true; } catch (InvocationTargetException e) { log.error("", e); return true; } return totalResult; }
From source file:org.seasar.struts.lessconfig.factory.AbstractValidatorAnnotationHandler.java
protected Field createField(Field field, PropertyDesc propDesc, String depends) { Field newField = new Field(); newField.setDepends(depends);//from ww w .j a va 2 s. c o m String property = getFieldProperty(field, propDesc); if (propDesc.getPropertyType().isArray()) { newField.setProperty(""); newField.setIndexedListProperty(property); } else { newField.setProperty(property); newField.setIndexedListProperty(field.getIndexedListProperty()); } return newField; }