Hello,
I implemented a buttonClick listener, and tried to issue a http client request to my custom VaadinServlet when button clicked. I tried to use JAX-RS/RESTEasy client to do that. The codes looked like:
@Override
public void buttonClick( Button.ClickEvent event ) {
Client client = ClientBuilder.newClient();
try {
WebTarget target = client.target( basePath )
.queryParam( “command”, “resetpassword” );
Invocation invoker = target.request().buildGet();
Future< Response > future = invoker.submit();
Response response = future.get( 10, TimeUnit.SECONDS );
String result = response.readEntity( String.class );
response.close();
}
catch ( TimeoutException e ) {
e.printStackTrace();
}
I used my IDE debuggging mode to monitor the the execution, and found some wierd results. When the button clicked, the invoker.submit() got executed, but no response got back. After 10 seconds, the timeout exception got caught and executed, and THEN my VaadinServlet received the client request and started to process the command. The question is that, event thought my VaadinServlet could successfully process the command, the UI could not get the response because the exception was already fired. I am wondering where I might go wrong. Please kindly advise.
Many thanks,
Joey