/** * Build and bind {@link ViewComponent}s to the properties of the property set. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void build() { propertyViews.clear(); // render and bind ViewComponents properties.forEach(p -> { // exclude hidden properties if (!isPropertyHidden(p)) { final Optional<ViewComponent> viewComponent = render(p); if (!viewComponent.isPresent() && !isIgnoreMissingViewComponent()) { throw new NoSuitableRendererAvailableException( "No ViewComponent render available to render the property [" + p.toString() + "] as a ViewComponent"); } viewComponent.ifPresent(v -> { // configure configureViewComponent(p, v); // bind propertyViews.put(p, v); }); } }); }
/** * Build and bind {@link ViewComponent}s to the properties of the property set. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void build() { propertyViews.clear(); // render and bind ViewComponents properties.forEach(p -> { // exclude hidden properties if (!isPropertyHidden(p)) { final Optional<ViewComponent> viewComponent = render(p); if (!viewComponent.isPresent() && !isIgnoreMissingViewComponent()) { throw new NoSuitableRendererAvailableException( "No ViewComponent render available to render the property [" + p.toString() + "] as a ViewComponent"); } viewComponent.ifPresent(v -> { // configure configureViewComponent(p, v); // bind propertyViews.put(p, v); }); } }); }
/** * Render given property as a {@link Input} and register the binding. * @param <T> Property type * @param property The property to render and bind */ protected <T> void renderAndBind(final Property<T> property) { // configuration final InputPropertyConfiguration<T> propertyConfiguration = configuration.get(property); // render final Input<T> component = render(propertyConfiguration) // configure input .map(input -> configureInput(propertyConfiguration, input)) // exception when Input not available .orElseThrow(() -> new NoSuitableRendererAvailableException( "No renderer available to render the property [" + property + "] as an Input")); // configure getPostProcessors().forEach(postProcessor -> postProcessor.accept(property, component)); // register components.set(property, component); }
/** * Render the {@link Input} and set it up in given property configuration. * @param <T> Property type * @param configuration Property configuration */ private <T> void renderAndBind(PropertyConfiguration<T> configuration) { final Optional<Input<T>> input = render(configuration.getProperty()); if (!input.isPresent() && !isIgnoreMissingInputs()) { throw new NoSuitableRendererAvailableException( "No Input renderer available to render the property [" + configuration.getProperty() + "]"); } input.ifPresent(i -> { // configure configureInput(configuration, i); // bind configuration.setInput(i); }); }
/** * Render given property as a {@link ViewComponent} and register the binding. * @param <T> Property type * @param property The property to render and bind */ protected <T> void renderAndBind(final Property<T> property) { if (property != null) { final ViewComponentPropertyConfiguration<T> propertyConfiguration = configuration.get(property); // render final ViewComponent<T> component = render(propertyConfiguration) .orElseThrow(() -> new NoSuitableRendererAvailableException( "No renderer available to render the property [" + property + "] as a ViewComponent")); // configure getPostProcessors().forEach(postProcessor -> postProcessor.accept(property, component)); // register components.set(property, component); } }
/** * Render this property as given <code>renderType</code>. * <p> * To successfully render the property, a suitable {@link PropertyRenderer} for given render type must be available * from the {@link PropertyRendererRegistry} obtained from current {@link Context} or from the default one for * current ClassLoader. * </p> * @param <R> Rendered object type * @param renderType Render type * @return Rendered property as given render type * @throws NoSuitableRendererAvailableException if no PropertyRenderer is available for this property and given * rendering type */ default <R> R render(Class<R> renderType) { return renderIfAvailable(renderType).orElseThrow(() -> new NoSuitableRendererAvailableException( "No PropertyRenderer available for rendering type " + renderType + " and property " + this)); }
/** * Render the {@link Input} and set it up in given property configuration. * @param <T> Property type * @param configuration Property configuration */ private <T> void renderAndBind(PropertyConfiguration<T> configuration) { final Optional<Input<T>> input = render(configuration.getProperty()); if (!input.isPresent() && !isIgnoreMissingInputs()) { throw new NoSuitableRendererAvailableException( "No Input renderer available to render the property [" + configuration.getProperty() + "]"); } input.ifPresent(i -> { // configure configureInput(configuration, i); // bind configuration.setInput(i); }); }