Question

I have a session scoped managed bean, with a property current. If I have a method

   public void resetCurrent() {
       current = new Configuration();
   }

in the bean, it gets called automatically every time I navigate to a new page in the application. Is this normal behavior? I am not calling the method anywhere in the code.

Considering that this approach to reset the session bean properties is, to say the least, less than ideal, which would be the right way to accomplish it?

Thank you.

Was it helpful?

Solution

JSF doesn't do that. It's your code which does that. Your view or another bean or maybe the bean itself is calling it. Putting a debug breakpoint on that line or adding Thread.dumpStack() should give you insights in who's calling it by reading the call stack. Or just rename the method to something else and check if you don't see compilation errors during build or get EL exceptions during runtime which should pinpoint the callers.


Considering that this approach to reset the session bean properties is, to say the least, less than ideal, which would be the right way to accomplish it?

Depends on the functional requirements. For example, if the bean is supposed to hold view scoped data, then put it in the view scope instead. Or if it is supposed to hold session scoped data (e.g. logged-in user) and you're basically logging out, then rather invalidate the session.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top