1

我正在使用 JSF 2.0 和在 Glassfish 3.1.2 上运行的 RichFaces 4.2.2。我已经创建了本地无状态会话 bean,它具有一个将由 JSF 托管 bean 调用的长时间运行的方法。

我希望能够将会话 bean 中的状态信息推送回托管 bean,以便我可以使用 RichFaces a4j:push 之类的东西将状态信息发送到浏览器。我相信这需要对会话 bean 方法的调用是异步的。当会话 bean 处理方法调用时,是否有将信息从会话 bean 推送回前端的模式?

4

1 回答 1

0

Stateless session beans (SLSB) are not supposed to hold any state (read: instance variables which are altered by the methods) because they are shared between all clients applicationwide. So they are useless to you if you need a session bean with some state which you can update during the process and which the client can request anytime. You need a stateful session bean (SFSB) instead. If you inject the SFSB in a session scoped JSF managed bean, then you'll be able to request the proper status from it and push it to the client throughout the HTTP session.

To understand the difference between SLSB and SFSB better, you may find this answer helpful: JSF request scoped bean keeps recreating new Stateful session beans on every request?

于 2012-05-29T16:48:34.047 回答