Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin IDE and components with constructor argument
Hello,
I'm trying to create a page using the Vaadin IDE. All works well until I try to add an invient chart.
The invient chart shows up in the component list on the design tab of the eclipse IDE, dragging it onto the page results in a new InvientCharts() being created.
@AutoGenerated
private VerticalLayout buildContent() {
// common part: create layout
content = new VerticalLayout();
content.setStyleName("content");
content.setImmediate(false);
content.setWidth("760px");
content.setHeight("400px");
content.setMargin(true);
...cut....
// invientCharts_1
[color=#fa0032]invientCharts_1 = new InvientCharts();[/color]
invientCharts_1.setImmediate(false);
invientCharts_1.setWidth("-1px");
invientCharts_1.setHeight("-1px");
content.addComponent(invientCharts_1);
...cut....
return content;
}
But the InvientChart expects a InvientChartsConfig as contructor parameter.
public StatisticsChart(InvientChartsConfig chartConfig) {
I'm using the invientChart as an example but there are probably more cases like this.
I can create the InvientChartsConfig in the application constructor, but I'm not able to add this because creation of the Chart is happening in a method that has @AutoGenerated annotation. meaning my changes will be erased.
I'm guessing I made a design mistake, can somebody give me an idea how this could be made to work?
Thanks
update: added some code to make it more clear.
Temmink UB: But the InvientChart expects a InvientChartsConfig as contructor parameter.
public StatisticsChart(InvientChartsConfig chartConfig) {
I'm using the invientChart as an example but there are probably more cases like this.
I can create the InvientChartsConfig in the application constructor, but I'm not able to add this because creation of the Chart is happening in a method that has @AutoGenerated annotation. meaning my changes will be erased.
Currently, the visual editor does not support custom components or widgets that do not have a default constructor, and I would not expect that to change in the near future.
If it would be possible to set the configuration after the constructor call (before or in the attach() method), you could subclass the chart component, provide such a setter and call the setter from the constructor of your CustomComponent after the main layout is constructed. You might also be able to wrap the chart in a class that has a no-args constructor and creates the chart with the correct constructor parameters.