summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-02-05 13:36:37 +0000
committerVaadin Code Review <review@vaadin.com>2013-02-05 13:36:37 +0000
commita5deb4e342f618e69a5f3a6cd5d3e2913a7cfae0 (patch)
tree0ca619ae0aa260b090de1392bf6737bbaf1c5175 /server/src/com/vaadin
parent6f70b60b411c229fe6a5b42c9d3b9a880a6f3ef3 (diff)
parent7c5aec1e34616d89726252f36c9650084c871ab9 (diff)
downloadvaadin-framework-a5deb4e342f618e69a5f3a6cd5d3e2913a7cfae0.tar.gz
vaadin-framework-a5deb4e342f618e69a5f3a6cd5d3e2913a7cfae0.zip
Merge "Merge of (#10312) to Vaadin 7." into 7.0
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/ui/Table.java102
1 files changed, 95 insertions, 7 deletions
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index e73c6d7188..10752140db 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -557,6 +557,8 @@ public class Table extends AbstractSelect implements Action.Container,
*/
private boolean keyMapperReset;
+ private List<Throwable> exceptionsDuringCachePopulation = new ArrayList<Throwable>();
+
/* Table constructors */
/**
@@ -1646,6 +1648,55 @@ public class Table extends AbstractSelect implements Action.Container,
setRowCacheInvalidated(true);
markAsDirty();
+ maybeThrowCacheUpdateExceptions();
+
+ }
+
+ private void maybeThrowCacheUpdateExceptions() {
+ if (!exceptionsDuringCachePopulation.isEmpty()) {
+ Throwable[] causes = new Throwable[exceptionsDuringCachePopulation
+ .size()];
+ exceptionsDuringCachePopulation.toArray(causes);
+
+ exceptionsDuringCachePopulation.clear();
+ throw new CacheUpdateException(this,
+ "Error during Table cache update", causes);
+ }
+
+ }
+
+ /**
+ * Exception thrown when one or more exceptions occurred during updating of
+ * the Table cache.
+ * <p>
+ * Contains all exceptions which occurred during the cache update.
+ * </p>
+ *
+ */
+ public static class CacheUpdateException extends RuntimeException {
+ private Throwable[] causes;
+ private Table table;
+
+ public CacheUpdateException(Table table, String message,
+ Throwable[] causes) {
+ super(message);
+ this.table = table;
+ this.causes = causes;
+ }
+
+ /**
+ * Returns the cause(s) for this exception
+ *
+ * @return the exception(s) which caused this exception
+ */
+ public Throwable[] getCauses() {
+ return causes;
+ }
+
+ public Table getTable() {
+ return table;
+ }
+
}
/**
@@ -2036,9 +2087,19 @@ public class Table extends AbstractSelect implements Action.Container,
cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
break;
default:
- cells[CELL_HEADER][i] = getItemCaption(id);
+ try {
+ cells[CELL_HEADER][i] = getItemCaption(id);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ cells[CELL_HEADER][i] = "";
+ }
+ }
+ try {
+ cells[CELL_ICON][i] = getItemIcon(id);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ cells[CELL_ICON][i] = null;
}
- cells[CELL_ICON][i] = getItemIcon(id);
}
GeneratedRow generatedRow = rowGenerator != null ? rowGenerator
@@ -2056,7 +2117,12 @@ public class Table extends AbstractSelect implements Action.Container,
boolean isGenerated = isGeneratedRow || isGeneratedColumn;
if (!isGenerated) {
- p = getContainerProperty(id, colids[j]);
+ try {
+ p = getContainerProperty(id, colids[j]);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ value = null;
+ }
}
if (isGeneratedRow) {
@@ -2089,7 +2155,12 @@ public class Table extends AbstractSelect implements Action.Container,
if (isGeneratedColumn) {
ColumnGenerator cg = columnGenerators
.get(colids[j]);
- value = cg.generateCell(this, id, colids[j]);
+ try {
+ value = cg.generateCell(this, id, colids[j]);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ value = null;
+ }
if (value != null && !(value instanceof Component)
&& !(value instanceof String)) {
// Avoid errors if a generator returns
@@ -2098,10 +2169,20 @@ public class Table extends AbstractSelect implements Action.Container,
value = value.toString();
}
} else if (iscomponent[j]) {
- value = p.getValue();
+ try {
+ value = p.getValue();
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ value = null;
+ }
listenProperty(p, oldListenedProperties);
} else if (p != null) {
- value = getPropertyValue(id, colids[j], p);
+ try {
+ value = getPropertyValue(id, colids[j], p);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ value = null;
+ }
/*
* If returned value is Component (via fieldfactory
* or overridden getPropertyValue) we expect it to
@@ -2114,7 +2195,12 @@ public class Table extends AbstractSelect implements Action.Container,
listenProperty(p, oldListenedProperties);
}
} else {
- value = getPropertyValue(id, colids[j], null);
+ try {
+ value = getPropertyValue(id, colids[j], null);
+ } catch (Exception e) {
+ exceptionsDuringCachePopulation.add(e);
+ value = null;
+ }
}
}
}
@@ -3049,6 +3135,7 @@ public class Table extends AbstractSelect implements Action.Container,
indexInRowbuffer, itemId);
}
target.endTag("urows");
+ maybeThrowCacheUpdateExceptions();
}
private void paintPartialRowAdditions(PaintTarget target,
@@ -3096,6 +3183,7 @@ public class Table extends AbstractSelect implements Action.Container,
target.addAttribute("firstprowix", firstIx);
target.addAttribute("numprows", count);
target.endTag("prows");
+ maybeThrowCacheUpdateExceptions();
}
/**