How to update the GUI from another thread?

前端 未结 2 952
长发绾君心
长发绾君心 2021-01-15 14:23

I have a problem with threads in my JSF application, maybe somebody could help me.

After the start I run new thread which is making some background

相关标签:
2条回答
  • 2021-01-15 14:25

    You can use JMS to communicate between the thread you've got running and your managed beans, but for the rest you'll need to use one of the push technologies as mentioned above.

    You could use the primefaces poll component if that's sufficient, otherwise the only push technology that works with jsf that I know of right now is icefaces push. Primefaces is coming out with a new websocket based push component that looks like it will be really nice, but I don't believe it's due to be finished for a couple of months (it showed up in the latest snapshot, but doesn't really do much yet and only works with jetty8). You could also do your own thing with the comet/atmosphere libraries, but having looked at that myself I can tell you those solutions would be a lot of work on your part, pretty much a custom implementation.

    0 讨论(0)
  • 2021-01-15 14:35

    Maybe you can solve your problem with asynchronous background work with ICEfaces server side push.
    Pleas take a look at http://auctionmonitor.icefaces.org/auctionMonitor/auctionMonitor.jsf for an example of the push technology.

    Your background working thread could perform a "push", which will "notify" certain pages to update (partially) and display your message.

    0 讨论(0)
提交回复
热议问题