Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support/document apps that use Vaadin for main UI as well #1

Open
mstahv opened this issue Dec 17, 2024 · 3 comments
Open

Add support/document apps that use Vaadin for main UI as well #1

mstahv opened this issue Dec 17, 2024 · 3 comments

Comments

@mstahv
Copy link
Member

mstahv commented Dec 17, 2024

url mapping etc is bit problematic currently, needs manual setup...

@mstahv
Copy link
Member Author

mstahv commented Dec 17, 2024

Quickly tested, this works on top of start.vaadin.com project. Needs to be cleaned and preferably configurable route prefix.

As a depdencency:

    <dependency>
        <groupId>in.virit.entityexplorer</groupId>
        <artifactId>entity-explorer-base</artifactId>
        <version>0.0.1</version>
    </dependency>

Spring Boot configuration (e.g. to @SpringBootApplication class):

@EventListener
void registerRoutes(ServiceInitEvent evt) {
    RouteConfiguration configuration = RouteConfiguration
            .forApplicationScope();
    configuration.setRoute("entityexplorerabout", About.class, TopLayout.class);
    Arrays.asList(EntityEditorView.class, EntityExplorer.class)
            .forEach(view -> {
                configuration.setAnnotatedRoute(view);
            });

    // Better error handling, e.g. with Grid & error in lazy loading from backend
    evt.getSource().addSessionInitListener(e -> {
        e.getSession().setErrorHandler((ErrorHandler) event -> {
            UI current = UI.getCurrent();
            if (current != null) {
                current.access(() -> Notification.show("Error: " + event.getThrowable().getMessage()));
            } else {
                event.getThrowable().printStackTrace();
            }
        });
    });
}

@mstahv
Copy link
Member Author

mstahv commented Dec 17, 2024

Preliminary instructions added in 29f603e

Keeping this open as a reminder to clean up/simplify.

@mstahv
Copy link
Member Author

mstahv commented Dec 18, 2024

Fixed some NPEs in 0.0.2 in case a custom parent layout was used (e.g. views registered to apps main layout, not sure if that is a "best practice" by any means though). Example:

https://github.com/mstahv/sakila-spring-data-jpa-starter/tree/postgres-with-vaadin-ui-stub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant