Skip to content

Commit

Permalink
Fix #586: Sheet error when pasting more rows than sheet contains.
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jul 5, 2018
1 parent 9c58261 commit 3f5daff
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -919,26 +919,27 @@ private void decodeSubmittedValues(final FacesContext context, final Sheet sheet
}

try {
// data comes in as a JSON Object with named properties for the row
// and columns updated
// this is so that multiple updates to the same cell overwrite
// previous deltas prior to submission
// we don't care about the property names, just the values, which
// we'll process in turn
// data comes in as a JSON Object with named properties for the row and columns updated this is so that
// multiple updates to the same cell overwrite previous deltas prior to submission we don't care about
// the property names, just the values, which we'll process in turn
final JSONObject obj = new JSONObject(jsonData);
final Iterator<String> keys = obj.keys();
while (keys.hasNext()) {
final String key = keys.next();
// data comes in: [row, col, oldValue, newValue, rowKey]
final JSONArray update = obj.getJSONArray(key);
// GitHub #586 pasted more values than rows
if (update.isNull(4)) {
continue;
}
final String rowKey = update.getString(4);
final int col = sheet.getMappedColumn(update.getInt(1));
final String newValue = String.valueOf(update.get(3));
sheet.setSubmittedValue(context, rowKey, col, newValue);
}
}
catch (final JSONException e) {
throw new FacesException("Failed parsing Ajax JSON message for cell change event:" + e.getMessage(), e);
catch (final JSONException ex) {
throw new FacesException("Failed parsing Ajax JSON message for cell change event:" + ex.getMessage(), ex);
}
}

Expand Down

0 comments on commit 3f5daff

Please sign in to comment.