简体   繁体   English

如何在 richfaces 3 和 seam 2 中不使用 a4j:keepAlive 来维护请求 scope bean 的 state?

[英]How to maintain state of a request scope bean without using a4j:keepAlive in richfaces 3 and seam 2?

I have problem pertaining to the maintaining state of the particular @Request scope bean.我有关于维护特定@Request scope bean state 的问题。 I have a Seam Entity List request scope component.我有一个 Seam 实体列表请求 scope 组件。 And after a particular request i want it to maintain its state and not to be refreshed, a4j:keepAlive do the solution but unfortunately using a4j:keepAlive destroy some other functionality inside a view so instead changing the whole page i just ignore a4j:keepAlive .在一个特定的请求之后,我希望它保持它的 state 并且不被刷新, a4j:keepAlive做解决方案但不幸的是使用a4j:keepAlive破坏了视图内的一些其他功能所以而不是改变整个页面我只是忽略a4j:keepAlive

My question is, how can i maintain this particular scenario without using a4j:keepAlive and without making my component into @SessionScope or @ConversationScope .我的问题是,如何在不使用a4j:keepAlive并且不将我的组件放入@SessionScope@ConversationScope的情况下维护这个特定场景。

If you're using JSF 2 for your website development, it would be better to use RichFaces 4. The RichFaces 3.3 is built to support JSF 1.2 mainly and then was extended to support JSF 2, still it doesn't take advantages of the benefits from JSF 2. RichFaces 4.x , in the other hand, is built thinking in JSF 2. It would be wise to move from RF 3.3 to RF 4, but if you still want to stick to RF 3.3, you should change the scope of your bean to ViewScope and stop using the a4j:keepAlive .如果您使用 JSF 2 进行网站开发,最好使用 RichFaces 4。RichFaces 3.3主要支持 JSF 1.2,然后扩展为支持 JSF 2,但仍然没有利用这些优势从 JSF 2. 另一方面, RichFaces 4.x是在 JSF 中构建的思想 2. 从 RF 3.3 移动到 RF 4 是明智的,但如果你仍然想坚持使用 RF 3.3,你应该改变 scope您的 bean 到 ViewScope 并停止使用a4j:keepAlive

More info:更多信息:

EDIT:编辑:

For your given problem, you should save the data in session and recover it when your Request Managed Bean is created, doing that your data will be preserved through your view, but you have to do the job manually (very hard to maintain, also).对于您给定的问题,您应该将数据保存在 session 中,并在创建 Request Managed Bean 时恢复它,这样做您的数据将通过您的视图保留,但您必须手动完成这项工作(也很难维护) .

If your managed bean has binding attributes with the jsp/facelet you're using, then don't use the a4j:keepAlive tag component, instead add the @KeepAlive(ajaxOnly=false) annotation to your request managed bean to save the entire state of your bean (even the binding components).如果您的托管 bean 具有与您正在使用的 jsp/facelet 的绑定属性,则不要使用a4j:keepAlive标记组件,而是将@KeepAlive(ajaxOnly=false)注释添加到您的请求托管 bean 以保存整个 state你的 bean(甚至是绑定组件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM