protected DataContext getDataContext() { DataLoader loader = container instanceof HasLoader ? ((HasLoader) container).getLoader() : null; return loader != null ? loader.getDataContext() : null; }
@Override public void refresh() { if (loader != null) { loader.load(); } }
protected void loadSoftDeletion(Element element, DataLoader loader) { String softDeletionVal = element.attributeValue("softDeletion"); if (!Strings.isNullOrEmpty(softDeletionVal)) loader.setSoftDeletion(Boolean.valueOf(softDeletionVal)); }
protected void loadQuery(Element element, DataLoader loader) { Element queryEl = element.element("query"); if (queryEl != null) { loader.setQuery(loadQueryText(queryEl)); Element conditionEl = queryEl.element("condition"); if (conditionEl != null) { if (!conditionEl.elements().isEmpty()) { if (conditionEl.elements().size() == 1) { Condition condition = conditionXmlLoader.fromXml(conditionEl.elements().get(0)); loader.setCondition(condition); } else { throw new IllegalStateException("'condition' element must have exactly one nested element"); } } } } }
@Override public void loadAll() { for (DataLoader loader : loaders.values()) { loader.load(); } }
protected <E extends Entity> void refreshItems(DataUnit dataSource) { CollectionContainer<E> container = dataSource instanceof ContainerDataUnit ? ((ContainerDataUnit) dataSource).getContainer() : null; if (container != null) { DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader != null) { loader.load(); } else { log.warn("Target container has no loader, refresh is impossible"); } } }
@Override public void actionPerform(Component component) { if (!hasSubscriptions(ActionPerformedEvent.class)) { if (!(target.getItems() instanceof ContainerDataUnit)) { throw new IllegalStateException("RefreshAction target is null or does not implement SupportsContainerBinding"); } CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer(); if (container == null) { throw new IllegalStateException("RefreshAction target is not bound to CollectionContainer"); } DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader != null) { loader.load(); } else { log.warn("RefreshAction '{}' target container has no loader, refresh is impossible", getId()); } } else { super.actionPerform(component); } } }
/** * Loads options of LookupFields if any. */ protected void refreshOptionsForLookupFields() { for (Component component : getForm().getOwnComponents()) { if (component instanceof LookupField) { Options options = ((LookupField) component).getOptions(); if (options instanceof ContainerOptions) { CollectionContainer container = ((ContainerOptions) options).getContainer(); if (container instanceof HasLoader) { DataLoader optionsLoader = ((HasLoader) container).getLoader(); if (optionsLoader != null) { optionsLoader.load(); } } } } } }