java - what is none scope bean and when to use it? -
could explain none scope , purpose of it?
suppose if have bean in
request scope r1 session scope s1 application scope a1
and inject none scope bean n1 in each of above scopes find n1 gets instantiated each parent bean when ever parent bean[r1/s1/a1] instantiated.
none scope bean in a1 available throughout in a1 since a1 appl scope. none scope bean in s1 available until s1 not destroyed , when s1 created again n1 instanciated , made available it.
is correct?
and purpose of using it? avoid creating such bean our self?
many thanks
a bean <managed-bean-scope>
of none
or @nonescoped
annotation created on every single el expression referencing bean. isn't been stored jsf anywhere. caller has got store evaluated reference itself, if necessary.
e.g. following in view
<p>#{nonescopedbean.someproperty}</p> <p>#{nonescopedbean.someproperty}</p> <p>#{nonescopedbean.someproperty}</p>
on none-scoped bean construct bean 3 (three) times during request. every access bean gives separate bean been garbaged after property access.
however, following in example session scoped bean
@managedproperty("#{nonescopedbean}") private nonescopedbean nonescopedbean;
will make live long session scoped bean instance. should make sure access in view #{sessionscopedbean.nonescopedbean.someproperty}
instead.
so may useful when want scope-less data being available managed property in arbitrary bean.
Comments
Post a Comment