Reputation: 1253
I have a JSF 1.2 app that has a session based bean. This bean is used for searching our database. On our homepage I have a few HTML controls with build up a URL of search parameters, which then sets the browser URL to the JSP. Since the bean is session based, the first time you access via the home page, the parameters are passed through correctly. However, subsequent access means the parameters are ignored as no functions in the bean are executed. What is the best way to force the init function in the bean to reload?
Upvotes: 1
Views: 1071
Reputation: 1109635
This is fully expected behavior for a session scoped bean. It's stored in the HTTP session and reused as long as the HTTP session lives and not recreated/reinitialized on every HTTP request. If you intend to recreate/reinitialize the bean on every HTTP request, then you should be placing it in the request scope instead.
However, if the bean represents a mix of request scoped data and session scoped data, then you should rather split down the bean in two separate beans, a request scoped one for the request scoped data and a session scoped one for the session scoped data. You can use <managed-property>
on the request scoped one to inject the session scoped one as a property of the request scoped one. This way you can put actions in the request scoped one which would need to access/manipulate the data of the session scoped one.
Upvotes: 2