|
Hello, I’m sure this question has been asked before, but I
must have missed something since I keep running into this issue. I have a session-scoped managed bean with a managed property
bound to a querystring parameter. JSF gives me the familiar exception: javax.faces.FacesException:
Property userId references object in a scope with shorter lifetime than the
target scope session Is there an easy solution to this problem? My workaround is to get the request parameter from the
ExternalContext in my property’s getter method. Just curious, is it too much to ask for JSF to manage the
lifetimes of both my session-scoped bean and my request-scoped property? For example, why is the following not permitted? <managed-bean> <managed-bean-name>userBean</managed-bean-name> <managed-bean-class>project.UserBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>userId</property-name> <value>#{param.userId}</value> </managed-property> </managed-bean> It would be nice if JSF interpreted this configuration as
follows: (Simplified) First request: - Apply Request Values - Create a new instance of UserBean - Store it in session scope - Look, there’s a “userId” parameter - Set the bean property with this value - Render Response Second request: If there is a “userId” parameter in the request,
update the property, else set it to null. Thanks for your help, Ian -- Ian Hlavats Tarantula Consulting |

