Java – using @ viewscoped? In JSF 2.0?

Usage / advantages of using @ viewscoped under @ managedbean in JSF 2.0

Solution

@Managedbean just declared that a bean is managed by JSF (making it available for expression language, etc.)

@Viewscoped allows you to declare a specific bean scope The default value (when no scope is specified) is @ requestscoped, which means that your bean will take effect through a request and then be destroyed Other scopes are @ sessionscope and @ applicationscope Third party extensions introduce additional scope

As long as you send back a page to yourself, @ viewscoped will stay alive "Page" in Java EE is another word of "page", but page range already means other content in Java EE The view range is very convenient because when you first visit the page (through a non face request (usually a get request)), you can initialize the data mode, and then retain the data when posting back on the page, AJAX requests, etc

When using a table in JSF that interacts with the components in the table, the scope is a savior In other words, there is a rule in JSF: the data used to render the table must be the execute same data used after processing the postback of the component interacting with it With this view, it is trivial, but it is quite difficult without it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>