@SuppressWarnings("unchecked") protected void loadContainer(T component, Element element) { String containerId = element.attributeValue("dataContainer"); String property = element.attributeValue("property"); // In case a component has only a property, // we try to obtain `dataContainer` from a parent element. // For instance, a component is placed within the Form component if (Strings.isNullOrEmpty(containerId) && property != null) { containerId = getParentDataContainer(element); } if (!Strings.isNullOrEmpty(containerId)) { if (property == null) { throw new GuiDevelopmentException( String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, component.getId()), context.getFullFrameId()); } FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (component instanceof HasValueSource) { ((HasValueSource) component).setValueSource(new ContainerValueSource<>(container, property)); } } }
((HasValueSource) dynamicAttrComponent).setValueSource(provider.getValueSource(code));