Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

@NoneScoped vs @RequestScoped?  RSS feed

 
Ranch Hand
Posts: 1723
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the difference between NoneScoped and RequestScoped?
According to Stackoverflow's comments, a none scoped bean lives as long as the EL expression is evaluated. But when the none scoped bean's EL expression is evaluated in one request/response, it has already gone through the lifecycle such as restore view, apply request, process validation, update model, invoke application , render response.
And a request scoped bean has to go through all the cycle in one request/response.
 
Ranch Hand
Posts: 90
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi. My two cents for this one.

It might be that difference is that the bean (for the EL) has not "gone through the lifecycle", but that
it lives and dies up to the point that the EL result is resolved, all inside the request response lifecycle...

Could not find anything in the EL Spec about this...
 
Mano Ag
Ranch Hand
Posts: 90
Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Found some information in the JEE Tutorial (6) under Chap 14 Configuring JavaServer Faces Applications /...Using Managed Bean Scopes

"You may want to use @NoneScoped when a managed bean references another managed bean. The second bean should not be in a scope (@NoneScoped) if it is supposed to be created only when it is
referenced. If you define a bean as @NoneScoped, the bean is instantiated anew each time it is referenced, so it does not get saved in any scope."

Please note that the corresponding section in the JEE Tutorial (7) 16.1.1 is reworded and makes no mention of the @NoneScoped annotation.
 
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himai Minh wrote:Hi, What is the difference between NoneScoped and RequestScoped?
According to Stackoverflow's comments, a none scoped bean lives as long as the EL expression is evaluated. But when the none scoped bean's EL expression is evaluated in one request/response, it has already gone through the lifecycle such as restore view, apply request, process validation, update model, invoke application , render response.
And a request scoped bean has to go through all the cycle in one request/response.



JSF spec 2.0's section 5.3.1 Managed Bean Configuration Example: This has an example of how a none scoped bean and a request scoped bean are configured and how they might be used together. To understand in detail you may have to write some code and verify the results. Here is the example:

A Customer bean with a request scope
An Address bean with none scope

The customer bean has attributes customer id, name, shipping address, billing address, etc. The shipping and billing address are of type Address. The customer bean creates an instance of address bean as shipping address and another instance as billing address; there will be two instances of address bean. The address bean instances do not have a scope, they are created as needed.
 
Himai Minh
Ranch Hand
Posts: 1723
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


index.xhtml


BeforeClick.JPG
[Thumbnail for BeforeClick.JPG]
Before click, fill out the name and the none scoped address
AfterClick.JPG
[Thumbnail for AfterClick.JPG]
After click, the user name is echo back, but not the address
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!