In Vaadin 14.6.1 Designer, when I create Vertical Layouts (and SplitLayouts) and then ask Vaadin designer to create an object in the java code that I can use to reference that component, instead of creating a "VerticalLayout" object, it simply creates an "Element" class. This "Element" class lacks all the critical methods of the normal "VerticalLayout" or "SplitLayout" class. I tried casting, but that failed. Is there a "right" way to get access to the underlying "correct" java object once I've created my layouts via Designer? I need to be able to a) set properties in code and b) even possibly create methods based on various events (eg the splitter position has changed etc.)
Asked
Active
Viewed 158 times
1
-
Can you share some code? – ollitietavainen Jun 02 '21 at 05:21
-
1It should not create "Element" classes in you Java companion file at all, but straight up "VerticalLayout" or "SplitLayout". I'm not sure what is wrong, but something definitely is. – Jens Jansson Jun 02 '21 at 05:31
-
1Casting the `Element` instance won't work, but one potential workaround could be to change the field type in the generated file. Another option for a workaround might be `element.as(VerticalLayout.class)`. – Leif Åstrand Jun 02 '21 at 06:05
-
@JensJansson I'll share some code, since it appears something is definitely wrong somewhere.... – Jonathan Sylvester Jun 02 '21 at 12:16
-
@LeifÅstrand So your suggestion seems to have worked, but I'll do some more testing. That said, is this "normal" behaviour for Vaadin Designer 14.x -- ie it will create "Element" objects for VerticalLayout and SplitLayouts? Shouldn't it just directly create the "true" class, eg VerticalLayout or SplitLayout so that this extra step is not needed? – Jonathan Sylvester Jun 03 '21 at 12:26
-
It's indeed supposed to generate code that uses the right component type. I'm not familiar enough with Designer to make any guesses on why it doesn't work as supposed for you. – Leif Åstrand Jun 03 '21 at 16:26
-
@LeifÅstrand At least on my system, Vaadin Designer 14.6.1 is *not* generating the correct class for some componenets, eg SplitLayout, VerticalLaout,HorizontalLayout; interestingly, it *is* generating the correct class for Board component (as well as Chart, Button, Label and others). Is this reproducible on Vaadin's side? – Jonathan Sylvester Jun 04 '21 at 20:08
2 Answers
2
Would you be so kind to create an issue in our Designer repository https://github.com/vaadin/designer? Please also attach your project (without dependencies) to it.
I'm not able to reproduce this issue, probably there is something in your project structure.
By the way, are you using Eclipse or IntelliJ IDEA?

szolo
- 247
- 1
- 4
- 15
2
If you have implemented Vertical Layouts (or SplitLayouts), Vaadin designer by default connects Element because it does not know which one to connect. Try to right-click the connection button and it will list all implemented component

ust3000
- 196
- 8
-
1This is true as well. You could pick server-side implementation via context menu of the connection button. – szolo Jun 09 '21 at 21:28