Reputation: 59
In my Vaadin 14 application, I want to open a website with the appropriate parameters when the user clicks on a button. The resource needs the parameters as the body of the post request. How can I open a new URL in Vaadin with a post request?
Upvotes: 1
Views: 450
Reputation: 8001
Navigating to a page as a POST request does in practice mean that a "traditional" <form>
should be submitted. Vaadin doesn't have high-level support for submitting forms in that way, but you can use low-level APIs such as new Element("form")
to create a server-side representation for the form itself, configure how it should work (e.g. defining the action
). Correspondingly, you can also use new Element("input")
to create hidden input fields with the data you want to submit in the body (assuming it should be posted as application/x-www-form-urlencoded
) and then submitting the form either through regular HTML button or through JS using formElement.callJsFunction("submit")
.
Upvotes: 0