Resolution: Won't Fix
Affects Version/s: 1.2.4
Fix Version/s: None
The problem with the current org.apache.myfaces.el.unified.resolver.GuiceResolver is that it doesn't take into account the managed-bean-scope from the ManagedBean configuration. Typically you end up with multiple instances of the managed bean (a new one every time the resolver is called) – ie, same as a managed-bean-scope of "none".
Note, there is some code in the resolver like this:
if (ectx == null ||
This works if there is already a request, session or application scope attribute with the given name, but if not, the managed bean is not added to the scope. You can see that the overriden "getValue" method from the ManagedBeanResolver was actually responsible for putting any new object into the scope via the "putInScope" method.
The simplest way to fix this in the code seems to be to make the ManagedBeanResolver.putInScope method "protected" (rather than private), and then call it from the GuiceResolver.getValue method whenever a new value is obtained from the injector.
Meanwhile, a work-around is to leverage the guice-servlet module and then to specify the scope in the guice module, something like this:
However, for that you have to list all your managed beans in two places (faces-config.xml as well as your guice module), and also have to add the com.google.inject.servlet.GuiceFilter filter class to your web app.
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|2526d 1h 54m||1||Thomas Andraschko||31/Aug/15 07:50|
|Status||Open [ 1 ]||Closed [ 6 ]|
|Resolution||Won't Fix [ 2 ]|
|Field||Original Value||New Value|
|Issue Type||Bug [ 1 ]||Improvement [ 4 ]|