开发者

Suggest the appropriate method of managing beans in Richfaces

开发者 https://www.devze.com 2023-02-14 21:46 出处:网络
The scenario is like this. I have a rich:tabPanel with about 5 tabs. On first tab there is a rich:datatable. When I click on first column\'s element (a4j:commandLink), I get another rich:datatable. Wh

The scenario is like this. I have a rich:tabPanel with about 5 tabs. On first tab there is a rich:datatable. When I click on first column's element (a4j:commandLink), I get another rich:datatable. When I click on first column's element (a4j:commandLink) of this table, I change the tab where I have another rich:datatable and the same thing follows as above. The constraints from previous tab is used to get elements for the current one. If I click on the tab directly I get all elements related to that tab. Each rich:datatable refers to different tables. Each table is interrelated. Each tab refers to a single managed bean. I am using hibernate in backend.

The problem starts now. I dont want the managed beans to be session or application based since there are many variables to store. If I give request scope, the following thing happens. The first table in the tab renders perfectly, however when I click on the first column, the second table doesn't use all constraints since the scope is request, for example actionlistener. What am I supposed开发者_如何转开发 to do ?

One thing I can do is define one managed bean for each table. Or forcefully use session scope. Or is there any other way? Please help.

Thanks.


If you are using Richfaces 3.0.0 or above you can annotate your bean with @KeepAlive or use the tag <a4j:keepAlive beanName="#{bean}" /> instead. This is an equivalent to the view scope in JSF 2.0.


If you're already on JSF 2.0, use view scope. It's a scope which lives as long as you're interacting with the same page (independently of the browser tab/session!).

If you're still on JSF 1.x, use request scope with an <a4j:keepAlive beanName="#{bean}" /> declared in the view. It behaves like the JSF 2.0 view scope.

0

精彩评论

暂无评论...
验证码 换一张
取 消