/* (non-Javadoc) * @see play.db.jpa.JPABase#_save() */ @Override public void _save() { this.registered = new Date(); super._save(); Form.invoke(Trigger.REGISTRATION, this); }
/** Get a sub-field, with a key relative to the current field. */ public Field sub(String key) { String subKey; if (key.startsWith("[")) { subKey = name + key; } else { subKey = name + "." + key; } return form.field(subKey); }
/** Return the indexes available for this field (for repeated fields ad List) */ public List<Integer> indexes() { List<Integer> result = new ArrayList<Integer>(); if (form.value().isDefined()) { BeanWrapper beanWrapper = new BeanWrapperImpl(form.value().get()); beanWrapper.setAutoGrowNestedPaths(true); String objectKey = name; if (form.name() != null && name.startsWith(form.name() + ".")) { objectKey = name.substring(form.name().length() + 1); } if (beanWrapper.isReadableProperty(objectKey)) { Object value = beanWrapper.getPropertyValue(objectKey); if (value instanceof Collection) { for (int i = 0; i < ((Collection) value).size(); i++) { result.add(i); } } } } else { java.util.regex.Pattern pattern = java.util.regex.Pattern.compile( "^" + java.util.regex.Pattern.quote(name) + "\\[(\\d+)\\].*$"); for (String key : form.data().keySet()) { java.util.regex.Matcher matcher = pattern.matcher(key); if (matcher.matches()) { result.add(Integer.parseInt(matcher.group(1))); } } } return result; }