protected void initDatasources(Window window, DsContext dsContext, @SuppressWarnings("unused") Map<String, Object> params) { ((LegacyFrame) window.getFrameOwner()).setDsContext(dsContext); for (Datasource ds : dsContext.getAll()) { if (Datasource.State.NOT_INITIALIZED.equals(ds.getState()) && ds instanceof DatasourceImplementation) { ((DatasourceImplementation) ds).initialized(); } } }
protected CollectionDatasource<Entity<Object>, Object> createOptionsDataSource(MetaClass metaClass) { CollectionDatasource ds = DsBuilder.create() .setMetaClass(metaClass) .setViewName(entityView) .buildCollectionDatasource(); ds.setRefreshOnComponentValueChange(true); ((DatasourceImplementation) ds).initialized(); if (!StringUtils.isBlank(entityWhere)) { QueryTransformer transformer = QueryTransformerFactory.createTransformer( "select e from " + metaClass.getName() + " e"); transformer.addWhere(entityWhere); String q = transformer.getResult(); ds.setQuery(q); } // TODO filter ds // if (WindowParams.DISABLE_AUTO_REFRESH.getBool(datasource.getDsContext().getFrameContext())) { // if (ds instanceof CollectionDatasource.Suspendable) // ((CollectionDatasource.Suspendable) ds).refreshIfNotSuspended(); // else ds.refresh(); // } return ds; }
protected void loadDsContext(@Nullable Element dsContextElement) { DsContext dsContext = null; if (resultComponent.getFrameOwner() instanceof LegacyFrame) { DsContextLoader dsContextLoader; DsContext parentDsContext = context.getParent().getDsContext(); if (parentDsContext != null){ dsContextLoader = new DsContextLoader(parentDsContext.getDataSupplier()); } else { dsContextLoader = new DsContextLoader(new GenericDataSupplier()); } dsContext = dsContextLoader.loadDatasources(dsContextElement, parentDsContext, getContext().getAliasesMap()); ((ComponentLoaderContext) context).setDsContext(dsContext); } if (dsContext != null) { FrameOwner frameOwner = getContext().getFrame().getFrameOwner(); if (frameOwner instanceof LegacyFrame) { LegacyFrame frame = (LegacyFrame) frameOwner; frame.setDsContext(dsContext); for (Datasource ds : dsContext.getAll()) { if (ds instanceof DatasourceImplementation) { ((DatasourceImplementation) ds).initialized(); } } dsContext.setFrameContext(resultComponent.getContext()); } } }