Client side Callback in GWT

扶醉桌前 提交于 2019-12-07 05:19:06

问题


I'm trying to create a logger for a GWT application as an exercise to evaluate GWT. What I specifically want to do is have it so that I can post messages to a client side label at any point from the server side. So, if some interesting stuff has happened on the server the client can be updated.

My First question is, is this possible, I can understand it not being.

Second, if it is possible, where should I look for information, I've tried google and their documentation and all the showcases have nothing on this.

Thanks


回答1:


Well, there are a couple of Options. You need to get the data from the server... So you either need to poll the server, or use server push.

Polling is pretty easy. Just use the Timer class to repeatedly call a service to see what value it should be displaying.

Server push is done using something like comet. here is one implementation for gwt that looks somewhat promising. They basic concept behind this is the browser sends a request to the server and keeps the connection open so the server is free to keep sending data back.

Comet is the better option if you can get it working. It will probably be simpler and scale better.

Good Luck!




回答2:


Polling is probably the best way to do what you're looking for. The big gotcha with GWT is that everything has to be serializable. I'm not sure if anything that can push to the browser can be easily serialized.



来源:https://stackoverflow.com/questions/187462/client-side-callback-in-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!