protected FormStatus createContextFormStatus(FormRenderContext context) throws Exception { Map<String, Object> loadedObjects = new HashMap<String, Object>(); Map values = readValuesToLoad(context.getForm(), context.getInputData(), context.getOutputData(), loadedObjects, context.getUID()); return getFormStatus(context.getForm(), context.getUID(), values, loadedObjects); }
public void persist(FormRenderContext context) throws Exception { Form form = context.getForm(); Map mapToPersist = getFilteredMapRepresentationToPersist(form, context.getUID()); Map<String, Object> result = context.getOutputData(); for (Iterator it = mapToPersist.keySet().iterator(); it.hasNext();) { String fieldName = (String) it.next(); Field field = form.getField(fieldName); if (field != null) { DataHolder holder = form.getDataHolderByField(field); String bindingString = field.getOutputBinding(); if (StringUtils.isEmpty(bindingString)) continue; Object value = persistField(field, mapToPersist, holder, context.getUID()); bindingString = bindingExpressionUtil.extractBindingExpression(bindingString); boolean simpleBinding = StringUtils.isEmpty(bindingString) || bindingString.indexOf("/") == -1; if (holder == null || simpleBinding) result.put(bindingString, value); else { String holderFieldId = bindingString.substring((holder.getOuputId() + "/").length()); Object holderOutputValue = result.get(holder.getOuputId()); if (holderOutputValue == null || !holder.isAssignableValue(holderOutputValue)) { holderOutputValue = context.getInputData().get(holder.getInputId()); if (holderOutputValue == null || !holder.isAssignableValue(holderOutputValue)) holderOutputValue = holder.createInstance(context); result.put(holder.getOuputId(), holderOutputValue); } holder.writeValue(holderOutputValue, holderFieldId, value); } } } }