vaadin front-end talking to REST services

Hi, Can someone point me to a tutorial or example where the vaadin front-end is consuming(doing GET/POST/DELETE/PUT) data to and from a REST endpoint ?

Hi,

there was a blog post by Matti Tahvonen about the topic a couple of years ago:
https://vaadin.com/blog/-/blogs/consuming-rest-services-from-java-applications

It’s a bit old, but I think the points still stand. The demo project referred to in the post can be found from GitHub:
https://github.com/mstahv/consuming-rest-apis

Hope this helps,
Olli

Thanks…i will check this out. What I am looking for is a simple entity CRUD based backend talking to a REST layer with vaadin front-end. I am thinking of using spring-boot with vaadin UI. Once done, I will share the details in a blog. Thanks for your response.

As suggested by Olli, my article is still perfectly valid. IIRC it don’t containe examples of PUT requests for saving, but it should be really easy to adapt for such use cases.

In spring stack, you can use JAX-RS as well, just include some implementation to your project. Or you can use Spring RestTemplate instead, but I think the standard JAX-RS Client APIs are bit better thought. Both will do fine for most use cases.

cheers,
matti

Hi,
I am developing a similar application with vaadin for java rest applications as developed by Matti Tahvonen. I am using eclipse IDE and wildfly application server. I have developed all the data object classes and the application deploys to the server without any errors on the console. However, the screen presents a message “Forbidden” when the application is deployed as shown in the attached picture. I have read other forums which have suggested to “inject” when calling a class instead of initiating the class with “New”. I have tried this suggestion but i still receive the “Forbidden” message on the screen when i deploy to the server. Please help me to solve this issue. Thanks in advance.
27801.jpg

Hi there. How are you deploying the application? do you have the server+project configured in eclipse, or o you start the server in som e pther way (e.g. command line)?

Hi Thomas,

Thanks for your response. I have the wildfly server and the project configured in eclipse

OK; I was asking because your URL looks wrong. If you deployed through eclipse, the url is normally just localhost:{port}/{projectname}/{servlet paths}, where project name is without versions and serlvet path is empty. Can you try that?

I have attached pics of the results of what you suggested. If there is no versions on the url, i get a “file not found message” so i add the version as deployed in the wildfly server in the attached “serverpic.jpg” file and with that i get the “forbidden” message
27901.jpg
27902.jpg

OK, thx. What do you have under project settings → web project settings, and also project settings → deployment assembly? How does yoir servlet definition look?

Please take a look at the attached pics. thanks
27903.jpg
27904.jpg

according to that, your URL really shouldn’t have the version number =/ I can’t really say what’s wrong based on the discussion here. It seems that there is something strange about how Wildfly routes those requests (come to think of it, do you have security restrictions in your web xml or in annotations?), but I can’t say for sure. I haven’t used wildfly 10 either, but I doubt that is the issue.

As a final thing, can you post your web.xml (and any jboss xml you might have) here?