开发者

Scope of a Static Variable in Seam

If I define a static variable in a class having Page Scope, then what will be the Scope of the Static Variable? Will it persist the data even if I navigate away from that page and then come back to that page(here by page I mean the xhtml page on which I am referring开发者_开发知识库 to the static variable)?


Static fields are associated with the class, rather than with any object. Seam Scopes don't change the meaning of static. The page context allows you to associate state with a particular instance, but if you assign a value to a static field that value will be share by all instances regardless of your Seam Scope.

Will it persist the data even if I navigate away from that page and then come back to that page(here by page I mean the xhtml page on which I am referring to the static variable)?

Yes, since you have one classloader for your web application, the scope of your static variable should be more than page scope.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜