I have an SVG element created using javascript inside a div with a specific ID. My primary goal would be to get the SVG image to let the user download it.
So my idea, which may absolutely be wrong, was to access the Div element (I'm using Vaadin 23), with container.getElement(), get the child element, which is my SVG and do svgElement.getOuterHTML() to obtain the string and save it somewhere. I can see the element and I know it's there, but when I print my container element from vaadin it doesn't have any children.
My situation:
<div class="chart-container" id="chart-div-02250ca9-3b1b-4d09-aeb2-f38c4c797fc9">
<div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="group" style="width: 100%; height: 100%; overflow: visible;">
...
</svg>
</div>
</div>
What I get from content.getElement().getOuterHTML(), where content is my div with the ID:
<div id="chart-div-02250ca9-3b1b-4d09-aeb2-f38c4c797fc9" class="chart-container">
</div>
What am I missing?
If this is the expected behaviour, how would you go about getting the SVG element? I tried with JS and then returing the result to Java but it was a real mess with Futures and all than synchronous stuff.
EDIT (adding clarification on final goal): The final goal is as follows: I want to add a feature where the user can download the rendered SVG as an image. But the thing is that I "build" the SVG at runtime, so I can't save it somewhere before the execution.