* The template to render
*/
public ListNotification(String id, String key, Template template) {
- super(id, template);
+ this(id, key, template, true);
+ }
+
+ /**
+ * Creates a new list notification.
+ *
+ * @param id
+ * The ID of the notification
+ * @param key
+ * The key under which to store the elements in the template
+ * @param template
+ * The template to render
+ * @param dismissable
+ * {@code true} if this notification should be dismissable by the
+ * user, {@code false} otherwise
+ */
+ public ListNotification(String id, String key, Template template, boolean dismissable) {
+ super(id, System.currentTimeMillis(), System.currentTimeMillis(), dismissable, template);
this.key = key;
template.getInitialContext().set(key, elements);
}
* The list notification to copy
*/
public ListNotification(ListNotification<T> listNotification) {
- super(listNotification.getId(), new Template());
+ super(listNotification.getId(), listNotification.getCreatedTime(), listNotification.getLastUpdatedTime(), listNotification.isDismissable(), new Template());
this.key = listNotification.key;
getTemplate().add(listNotification.getTemplate());
getTemplate().getInitialContext().set(key, elements);
}
/**
+ * Sets the elements to show in this notification.
+ *
+ * @param elements
+ * The elements to show
+ */
+ public void setElements(Collection<? extends T> elements) {
+ this.elements.clear();
+ this.elements.addAll(elements);
+ touch();
+ }
+
+ /**
* Returns whether there are any new elements.
*
* @return {@code true} if there are no new elements, {@code false} if there