Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Rework mechanism for registering external components #1

Closed
GlebDurygin opened this issue Aug 7, 2020 · 0 comments
Closed

Rework mechanism for registering external components #1

GlebDurygin opened this issue Aug 7, 2020 · 0 comments
Assignees
Milestone

Comments

@GlebDurygin
Copy link
Contributor

GlebDurygin commented Aug 7, 2020

Consider using annotation instead of xsd for defining component model

Port:

  • ExternalUIComponentsSource interface
  • WebExternalUIComponentsSource class

Without this mechanism, the user cannot register custom or composite component


Changes

The mechanism of registering/overriding UI components is simplified to defining spring bean (ComponentRegistration) with component information.

For instance:

@Configuration
public class MyComponentsConfiguration {

    @Bean
    protected ComponentRegistration newButton() {
        return ComponentRegistrationBuilder.create(NewButton.NAME)
                .withComponentClass(NewWebButton.class)
                .withComponentLoaderClass(NewButtonLoader.class)
                .build();
    }
}

The code above will register new Button component with:

  • name: NewButton.NAME;
  • class: NewWebButton.class;
  • XML tag name: NewButton.NAME;
  • loader class: NewButtonLoader.class;

ComponentRegistration is an interface for registering components.
ComponentRegistrationBuilder is a builder class for creating registration bean.

Order of registering components

It is possible to use spring @Order annotation to handle the order of registering components. For instance, we have two configurations:

  • configuration from some add-on:
@Bean
@Order(200)
protected ComponentRegistration newButton() {
    return ComponentRegistrationBuilder.create(Chart.NAME)
            .withComponentClass(WebChart.class)
            .withComponentLoaderClass(ChartLoader.class)
            .build();
}
  • project configuration with component overriding WebChart component:
@Bean
@Order(100)
protected ComponentRegistration newButton() {
    return ComponentRegistrationBuilder.create(Chart.NAME)
            .withComponentClass(MyWebChart.class)
            .withComponentLoaderClass(ChartLoader.class)
            .build();
}

So with the above configurations will be registered component with the smallest @Order value (MyWebChart).

Important note
You must specify loader class for MyWebChart component as it "replace" registration of WebChart component and all information about WebChart is lost.

@GlebDurygin GlebDurygin added this to the M2 milestone Aug 7, 2020
@knstvk knstvk modified the milestones: M2, 0.1.0 Aug 24, 2020
@web-devel web-devel assigned Flaurite and unassigned web-devel Sep 7, 2020
@Flaurite Flaurite changed the title Port the mechanism for registering external components Rework mechanism for registering external components Oct 1, 2020
Flaurite added a commit to jmix-projects/jmix-cuba that referenced this issue Oct 1, 2020
@Flaurite Flaurite closed this as completed Oct 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants