// get element formatted data
FormRowSet elementResult = element.formatData(formData);
if (elementResult != null) {
if (!elementResult.isMultiRow()) {
// get single row
FormRow elementRow = elementResult.get(0);
// append to consolidated row set
if (rowSet.isEmpty()) {
rowSet.add(elementRow);
} else {
FormRow currentRow = rowSet.get(0);
currentRow.putAll(elementRow);
}
} else {
//if the store binder of this element is null, store as single row in json format
if (element.getStoreBinder() == null) {
try {
// create json object
JSONArray jsonArray = new JSONArray();
for (FormRow row : elementResult) {
JSONObject jsonObject = new JSONObject();
for (Map.Entry entry : row.entrySet()) {
String key = (String) entry.getKey();
String value = (String) entry.getValue();
jsonObject.put(key, value);
}
//File upload is not support when no binder is set.
jsonArray.put(jsonObject);
}
// convert into json string
String json = jsonArray.toString();
// store in single row FormRowSet
String id = element.getPropertyString(FormUtil.PROPERTY_ID);
FormRow elementRow = new FormRow();
elementRow.put(id, json);
// append to consolidated row set
if (rowSet.isEmpty()) {
rowSet.add(elementRow);
} else {
FormRow currentRow = rowSet.get(0);
currentRow.putAll(elementRow);
}
} catch (JSONException ex) {
LogUtil.error(FormUtil.class.getName(), ex, "");
}
} else {