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

Using Component instead of VerticalLayout removes TextFields #8115

Open
chufgard opened this issue Apr 20, 2020 · 10 comments
Open

Using Component instead of VerticalLayout removes TextFields #8115

chufgard opened this issue Apr 20, 2020 · 10 comments

Comments

@chufgard
Copy link

Description of the bug
Instead of using public CreateTab(CustomerData customerData, ChapterSelection chapterSelection, Download download) { I used public CreateTab(Component customerData, ChapterSelection chapterSelection, Download download) {.

Spring was able to find the import since the parameter name was identical to the bean name automatically generated from the class.

After running mvn install -P production running the application (even local) show a UI without any TextField

Minimal reproducible example

@UIScope
@Route(value = "")
public class CreateTab extends VerticalLayout {

    public CreateTab(Component customerData) {
        //new TextField();
        add(customerData);
    }
}
@UIScope
public class CustomerData extends VerticalLayout {
    
    CustomerData() {
        add(new TextField());
    }
}

Add this two classes to a clean vaadin starter project and remove the default ui elements.

If you do a mvn install -P production the UI is broken. If you enable the TextField in CreateTab it works again.

Expected behavior
A TextField should be rendered even if injected with Component instead of VerticalLayout

  • Actual behavior
    TextField is not rendered if injected with Component instead of VerticalLayout

Versions
- Vaadin / Flow version
14.2.5
- Java version
11

https://vaadin.com/forum/thread/18215575/production-mode-breaks-textfield

@caalador
Copy link
Contributor

caalador commented Apr 23, 2020

Should the Vaadin version be 14.1.5?
14.2 series is only out as a prerelease 14.2.0.alpha11 with the beta1 coming soon.

If using 14.1.5 could you update to 14.1.25 to see if the issue still persists.

@musikpirat
Copy link

Should the Flow version be 14.1.5?
14.2 series is only out as a prerelease 14.2.0.alpha11 with the beta1 coming soon.

If using 14.1.5 could you update to 14.1.25 to see if the issue still persists.

Sorry for the confusion, 14.2.5 is the Vaadin version (LTS).

@caalador
Copy link
Contributor

caalador commented Apr 23, 2020

I'm also miss typing. Vaadin 14.1.25 is the newest LTS that is out. Vaadin 14.2.0.beta1 is on its way, but not yet out.

@musikpirat
Copy link

You're totally right. Of couse I meant 14.1.25.

Martin Israelsen guesed in the forum, that the issue might be related to the optimizer.

@caalador
Copy link
Contributor

How did you get Spring to accept Component in the constructor as it's not a bean?

@musikpirat
Copy link

Once again I have to beg for pardon. This is my worst bug report ever...

Of course CustomerData ist annotated with @component. Should have uploaded my test project.

@caalador caalador added the bug label Apr 23, 2020
@caalador caalador moved this from Needs triage to New P2 in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) Apr 23, 2020
@caalador
Copy link
Contributor

That's fine I got it to replicate as described.

@musikpirat
Copy link

Great! Thanks for your patience!

@cdir
Copy link

cdir commented Jun 19, 2023

As far as I can see, this problem got worse with Vaadin 24.1. We use injection to make certain parts of the UI configurable by downstream projects. All components that are only referenced in the downstream project are no longer part of the delivered bundle.

We can't use @Uses annotation here because the classes annotated with @Route are already defined in the upstream project. However, the component scan will only find classes that are referenced by a class annotated with @Route.

It would be helpful if we can specify other classes, e.g. at AppShellConfigurator, which are also considered in the Component Scan. Also, since we often work with configuration interfaces that provide methods for the various components used, it would be helpful if the @Uses annotation accepted arbitrary classes and not just classes of type Component.

@Artur-
Copy link
Member

Artur- commented Jun 19, 2023

You should be able to use

/**
* Whether to use byte code scanner strategy to discover frontend
* components.
*/
@Parameter(defaultValue = "true")
private boolean optimizeBundle;
to make it include all components it finds on the classpath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Development

No branches or pull requests

5 participants