As for Q1 and Q2: I suppose, you may at least use httpclient or core http protocol support form java and make a regular http request from the server to your servlet. Then parse or do whatever you want with the response, update the UI controls of your app with the data from that response, etc. HttpClient has higher level HTTP API, so probably it will be easier to use.
Q3: As a variant: In button’s click listener, remove your button from the UI and add a progress indicator in button’s place. Then spawn a new thread which will be calling your stand-alone servlet. When that thread is finished getting data form a servlet, update the UI with that data, remove progress bar and return button back to reset the UI state. Do not forget to perform all UI values update and progress bar removal stuff being synchronized to an application instance.
As another variant, my
tpt extra package contains a special TPTLazyLoadingLayout which automatically performs thread spawning, progress indicator manipulation and UI substitutions for such cases, so you may use it or take it as a starting/information point. You may check the
tpt online demo (see “widgets” tab ) to see how it works.
Hi Dimitri!
Thank you very much for your quick answer!
Since I am quite new to vaadin, I am not sure if I follow you.
Maybe you can give an example of the code for the button, and how to handle the response.
I will indeed look at your examples you provided.
for example on how to add a click listener to a button please check the
sampler
for the example on how to connect to another web page/servlet/whatever else you can check the documentation for
Apache HttpClient , in short words this will look like as follows: